├── vendor ├── github.com │ ├── docker │ │ ├── docker │ │ │ ├── pkg │ │ │ │ └── term │ │ │ │ │ ├── MAINTAINERS │ │ │ │ │ ├── tc_other.go │ │ │ │ │ ├── tc_linux_cgo.go │ │ │ │ │ ├── termios_linux.go │ │ │ │ │ ├── termios_darwin.go │ │ │ │ │ ├── termios_freebsd.go │ │ │ │ │ ├── console_windows.go │ │ │ │ │ ├── term.go │ │ │ │ │ └── term_windows.go │ │ │ └── NOTICE │ │ └── machine │ │ │ ├── libmachine │ │ │ ├── version │ │ │ │ └── version.go │ │ │ ├── engine │ │ │ │ └── engine.go │ │ │ ├── log │ │ │ │ ├── machine_logger.go │ │ │ │ ├── history_recorder.go │ │ │ │ ├── log.go │ │ │ │ └── fmt_machine_logger.go │ │ │ ├── state │ │ │ │ └── state.go │ │ │ ├── mcnflag │ │ │ │ └── flag.go │ │ │ ├── drivers │ │ │ │ ├── plugin │ │ │ │ │ ├── register_driver.go │ │ │ │ │ └── localbinary │ │ │ │ │ │ └── plugin.go │ │ │ │ ├── utils.go │ │ │ │ ├── check.go │ │ │ │ ├── notsupported.go │ │ │ │ ├── base.go │ │ │ │ ├── drivers.go │ │ │ │ ├── serial.go │ │ │ │ └── rpc │ │ │ │ │ └── server_driver.go │ │ │ ├── mcnutils │ │ │ │ └── utils.go │ │ │ └── ssh │ │ │ │ └── keys.go │ │ │ └── version │ │ │ └── version.go │ ├── stretchr │ │ ├── objx │ │ │ ├── README.md │ │ │ ├── security.go │ │ │ ├── .gitignore │ │ │ ├── constants.go │ │ │ ├── tests.go │ │ │ ├── LICENSE.md │ │ │ ├── value.go │ │ │ ├── mutations.go │ │ │ ├── doc.go │ │ │ ├── conversions.go │ │ │ ├── accessors.go │ │ │ └── map.go │ │ └── testify │ │ │ ├── assert │ │ │ ├── assertion_forward.go.tmpl │ │ │ ├── errors.go │ │ │ ├── forward_assertions.go │ │ │ ├── doc.go │ │ │ └── http_assertions.go │ │ │ ├── LICENSE │ │ │ ├── LICENCE.txt │ │ │ └── mock │ │ │ └── doc.go │ ├── dghubble │ │ └── sling │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── CHANGES.md │ │ │ └── doc.go │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ ├── bypasssafe.go │ │ │ ├── bypass.go │ │ │ └── spew.go │ ├── pmezard │ │ └── go-difflib │ │ │ └── LICENSE │ └── google │ │ └── go-querystring │ │ ├── LICENSE │ │ └── query │ │ └── encode.go └── golang.org │ └── x │ └── crypto │ ├── ssh │ ├── terminal │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ ├── util.go │ │ └── util_windows.go │ ├── doc.go │ ├── mac.go │ ├── buffer.go │ ├── connection.go │ └── client.go │ ├── curve25519 │ ├── const_amd64.s │ ├── doc.go │ ├── cswap_amd64.s │ ├── freeze_amd64.s │ ├── square_amd64.s │ ├── mul_amd64.s │ └── mont25519_amd64.go │ ├── PATENTS │ └── LICENSE ├── cloud ├── Console.go ├── SSHKeyCreate.go ├── ModelError.go ├── SSHKeyList.go ├── ServerList.go ├── AddressList.go ├── ServerActionList.go ├── Pagination.go ├── SSHKey.go ├── ServerAction.go ├── IpAddress.go ├── ServerCreate.go ├── client.go └── Server.go ├── Godeps ├── Readme └── Godeps.json ├── bin └── main.go ├── .gitignore ├── install.sh ├── scripts └── integration-test.sh ├── LICENSE.md ├── Makefile ├── README.md └── godaddy_test.go /vendor/github.com/docker/docker/pkg/term/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Solomon Hykes (@shykes) 2 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/README.md: -------------------------------------------------------------------------------- 1 | # objx 2 | 3 | * Jump into the [API Documentation](http://godoc.org/github.com/stretchr/objx) 4 | -------------------------------------------------------------------------------- /cloud/Console.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type Console struct { 4 | Type_ string `json:"type,omitempty"` 5 | Url string `json:"url,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /cloud/SSHKeyCreate.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type SSHKeyCreate struct { 4 | Key string `json:"key,omitempty"` 5 | Name string `json:"name,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /cloud/ModelError.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type ModelError struct { 4 | Message string `json:"message,omitempty"` 5 | Code string `json:"code,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /cloud/SSHKeyList.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type SSHKeyList struct { 4 | Results []SSHKey `json:"results,omitempty"` 5 | Pagination Pagination `json:"pagination,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /cloud/ServerList.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type ServerList struct { 4 | Results []Server `json:"results,omitempty"` 5 | Pagination Pagination `json:"pagination,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /cloud/AddressList.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type AddressList struct { 4 | Results []IpAddress `json:"results,omitempty"` 5 | Pagination Pagination `json:"pagination,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /cloud/ServerActionList.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type ServerActionList struct { 4 | Results []ServerAction `json:"results,omitempty"` 5 | Pagination Pagination `json:"pagination,omitempty"` 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /cloud/Pagination.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type Pagination struct { 4 | Limit int32 `json:"limit,omitempty"` 5 | Prev string `json:"prev,omitempty"` 6 | Next string `json:"next,omitempty"` 7 | Total int64 `json:"total,omitempty"` 8 | } 9 | -------------------------------------------------------------------------------- /bin/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/docker/machine/libmachine/drivers/plugin" 5 | "github.com/godaddy/docker-machine-godaddy" 6 | ) 7 | 8 | func main() { 9 | plugin.RegisterDriver(godaddy.NewDriver("", "")) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/dghubble/sling/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5.3 4 | - 1.6 5 | - tip 6 | before_install: 7 | - go get github.com/golang/lint/golint 8 | install: 9 | - go get -v . 10 | script: 11 | - go test -v . 12 | - go vet ./... 13 | - golint ./... -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The standard Go .gitignore file follows. (Sourced from: github.com/github/gitignore/master/Go.gitignore) 2 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 3 | *.o 4 | *.a 5 | *.so 6 | 7 | # Folders 8 | _obj 9 | _test 10 | 11 | bin/docker-machine-* 12 | release/ 13 | 14 | *~ 15 | *.swp -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security 9 | // key. 10 | func HashWithKey(data, key string) string { 11 | hash := sha1.New() 12 | hash.Write([]byte(data + ":" + key)) 13 | return hex.EncodeToString(hash.Sum(nil)) 14 | } 15 | -------------------------------------------------------------------------------- /cloud/SSHKey.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type SSHKey struct { 8 | Fingerprint string `json:"fingerprint,omitempty"` 9 | Name string `json:"name,omitempty"` 10 | SshKeyId string `json:"sshKeyId,omitempty"` 11 | CreatedAt time.Time `json:"createdAt,omitempty"` 12 | ModifiedAt time.Time `json:"modifiedAt,omitempty"` 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/constants.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | const ( 4 | // PathSeparator is the character used to separate the elements 5 | // of the keypath. 6 | // 7 | // For example, `location.address.city` 8 | PathSeparator string = "." 9 | 10 | // SignatureSeparator is the character that is used to 11 | // separate the Base64 string from the security signature. 12 | SignatureSeparator = "_" 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | var ( 4 | // APIVersion dictates which version of the libmachine API this is. 5 | APIVersion = 1 6 | 7 | // ConfigVersion dictates which version of the config.json format is 8 | // used. It needs to be bumped if there is a breaking change, and 9 | // therefore migration, introduced to the config file format. 10 | ConfigVersion = 3 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | VERSION=v1.0.0 6 | REPO=https://github.com/godaddy/docker-machine-godaddy 7 | 8 | echo "Downloading driver..." 9 | curl -L ${REPO}/releases/download/${VERSION}/docker-machine-driver-godaddy-$(uname -s) > docker-machine-driver-godaddy 10 | 11 | echo "Installing..." 12 | chmod +x docker-machine-driver-godaddy 13 | mv docker-machine-driver-godaddy /usr/local/bin/ 14 | 15 | echo "Install complete." 16 | exit 0 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /cloud/ServerAction.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type ServerAction struct { 8 | Status string `json:"status,omitempty"` 9 | ServerActionId string `json:"serverActionId,omitempty"` 10 | CreatedAt time.Time `json:"createdAt,omitempty"` 11 | ModifiedAt time.Time `json:"modifiedAt,omitempty"` 12 | Type_ string `json:"type,omitempty"` 13 | CompletedAt *time.Time `json:"completedAt,omitempty"` 14 | ServerId string `json:"serverId,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/tc_other.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !linux !cgo 3 | 4 | package term 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | func tcget(fd uintptr, p *Termios) syscall.Errno { 12 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(p))) 13 | return err 14 | } 15 | 16 | func tcset(fd uintptr, p *Termios) syscall.Errno { 17 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(p))) 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/engine/engine.go: -------------------------------------------------------------------------------- 1 | package engine 2 | 3 | const ( 4 | DefaultPort = 2376 5 | ) 6 | 7 | type Options struct { 8 | ArbitraryFlags []string 9 | DNS []string `json:"Dns"` 10 | GraphDir string 11 | Env []string 12 | Ipv6 bool 13 | InsecureRegistry []string 14 | Labels []string 15 | LogLevel string 16 | StorageDriver string 17 | SelinuxEnabled bool 18 | TLSVerify bool `json:"TlsVerify"` 19 | RegistryMirror []string 20 | InstallURL string 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/machine_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import "io" 4 | 5 | type MachineLogger interface { 6 | SetDebug(debug bool) 7 | 8 | SetOutWriter(io.Writer) 9 | SetErrWriter(io.Writer) 10 | 11 | Debug(args ...interface{}) 12 | Debugf(fmtString string, args ...interface{}) 13 | 14 | Error(args ...interface{}) 15 | Errorf(fmtString string, args ...interface{}) 16 | 17 | Info(args ...interface{}) 18 | Infof(fmtString string, args ...interface{}) 19 | 20 | Warn(args ...interface{}) 21 | Warnf(fmtString string, args ...interface{}) 22 | 23 | History() []string 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | var ( 9 | // Version should be updated by hand at each release 10 | Version = "0.7.0" 11 | 12 | // GitCommit will be overwritten automatically by the build system 13 | GitCommit = "HEAD" 14 | ) 15 | 16 | // FullVersion formats the version to be printed 17 | func FullVersion() string { 18 | return fmt.Sprintf("%s, build %s", Version, GitCommit) 19 | } 20 | 21 | // RC checks if the Machine version is a release candidate or not 22 | func RC() bool { 23 | return strings.Contains(Version, "rc") 24 | } 25 | -------------------------------------------------------------------------------- /cloud/IpAddress.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type IpAddress struct { 8 | Status string `json:"status,omitempty"` 9 | Version string `json:"version,omitempty"` 10 | ZoneId string `json:"zoneId,omitempty"` 11 | CreatedAt time.Time `json:"createdAt,omitempty"` 12 | Address string `json:"address,omitempty"` 13 | AddressId string `json:"addressId,omitempty"` 14 | Type_ string `json:"type,omitempty"` 15 | DataCenterId string `json:"dataCenterId,omitempty"` 16 | ModifiedAt time.Time `json:"modifiedAt,omitempty"` 17 | ServerId string `json:"serverId,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/state/state.go: -------------------------------------------------------------------------------- 1 | package state 2 | 3 | // State represents the state of a host 4 | type State int 5 | 6 | const ( 7 | None State = iota 8 | Running 9 | Paused 10 | Saved 11 | Stopped 12 | Stopping 13 | Starting 14 | Error 15 | Timeout 16 | ) 17 | 18 | var states = []string{ 19 | "", 20 | "Running", 21 | "Paused", 22 | "Saved", 23 | "Stopped", 24 | "Stopping", 25 | "Starting", 26 | "Error", 27 | "Timeout", 28 | } 29 | 30 | // Given a State type, returns its string representation 31 | func (s State) String() string { 32 | if int(s) >= 0 && int(s) < len(states) { 33 | return states[s] 34 | } 35 | return "" 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/const_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | DATA ·REDMASK51(SB)/8, $0x0007FFFFFFFFFFFF 11 | GLOBL ·REDMASK51(SB), 8, $8 12 | 13 | DATA ·_121666_213(SB)/8, $996687872 14 | GLOBL ·_121666_213(SB), 8, $8 15 | 16 | DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA 17 | GLOBL ·_2P0(SB), 8, $8 18 | 19 | DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE 20 | GLOBL ·_2P1234(SB), 8, $8 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/NOTICE: -------------------------------------------------------------------------------- 1 | Docker 2 | Copyright 2012-2014 Docker, Inc. 3 | 4 | This product includes software developed at Docker, Inc. (http://www.docker.com). 5 | 6 | This product contains software (https://github.com/kr/pty) developed 7 | by Keith Rarick, licensed under the MIT License. 8 | 9 | The following is courtesy of our legal counsel: 10 | 11 | 12 | Use and transfer of Docker may be subject to certain restrictions by the 13 | United States and other governments. 14 | It is your responsibility to ensure that your use and/or transfer does not 15 | violate applicable laws. 16 | 17 | For more information, please see http://www.bis.doc.gov 18 | 19 | See also http://www.apache.org/dev/crypto.html and/or seek legal counsel. 20 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | */ 18 | package ssh 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/history_recorder.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | type HistoryRecorder struct { 9 | lock *sync.Mutex 10 | records []string 11 | } 12 | 13 | func NewHistoryRecorder() *HistoryRecorder { 14 | return &HistoryRecorder{ 15 | lock: &sync.Mutex{}, 16 | records: []string{}, 17 | } 18 | } 19 | 20 | func (ml *HistoryRecorder) History() []string { 21 | return ml.records 22 | } 23 | 24 | func (ml *HistoryRecorder) Record(args ...interface{}) { 25 | ml.lock.Lock() 26 | defer ml.lock.Unlock() 27 | ml.records = append(ml.records, fmt.Sprint(args...)) 28 | } 29 | 30 | func (ml *HistoryRecorder) Recordf(fmtString string, args ...interface{}) { 31 | ml.lock.Lock() 32 | defer ml.lock.Unlock() 33 | ml.records = append(ml.records, fmt.Sprintf(fmtString, args...)) 34 | } 35 | -------------------------------------------------------------------------------- /cloud/ServerCreate.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type ServerCreate struct { 4 | BackupsEnabled bool `json:"backupsEnabled,omitempty"` 5 | SshKeyId string `json:"sshKeyId,omitempty"` 6 | Volumes []string `json:"volumes,omitempty"` 7 | DataCenterId string `json:"dataCenterId,omitempty"` 8 | Addresses []string `json:"addresses,omitempty"` 9 | Spec string `json:"spec,omitempty"` 10 | Description string `json:"description,omitempty"` 11 | ZoneId string `json:"zoneId,omitempty"` 12 | Password string `json:"password,omitempty"` 13 | Hostname string `json:"hostname,omitempty"` 14 | BootScript string `json:"bootScript,omitempty"` 15 | Username string `json:"username,omitempty"` 16 | Discount string `json:"discount,omitempty"` 17 | Image string `json:"image,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /cloud/client.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | type Client struct { 4 | sshKeys *SshKeysApi 5 | servers *ServersApi 6 | } 7 | 8 | type ServersClient interface { 9 | AddServer(body ServerCreate) (Server, error) 10 | GetServerById(serverId string) (Server, error) 11 | StartServer(serverId string) (ServerAction, error) 12 | StopServer(serverId string) (ServerAction, error) 13 | DestroyServer(serverId string) (ServerAction, error) 14 | } 15 | 16 | type ClientWrapper interface { 17 | SSHKeys() *SshKeysApi 18 | Servers() ServersClient 19 | } 20 | 21 | func NewClient(basePath, apiKey string) ClientWrapper { 22 | return &Client{ 23 | sshKeys: NewSshKeysApi(basePath, apiKey), 24 | servers: NewServersApi(basePath, apiKey), 25 | } 26 | } 27 | 28 | func (c *Client) SSHKeys() *SshKeysApi { 29 | return c.sshKeys 30 | } 31 | 32 | func (c *Client) Servers() ServersClient { 33 | return c.servers 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package curve25519 provides an implementation of scalar multiplication on 6 | // the elliptic curve known as curve25519. See http://cr.yp.to/ecdh.html 7 | package curve25519 8 | 9 | // basePoint is the x coordinate of the generator of the curve. 10 | var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 11 | 12 | // ScalarMult sets dst to the product in*base where dst and base are the x 13 | // coordinates of group points and all values are in little-endian form. 14 | func ScalarMult(dst, in, base *[32]byte) { 15 | scalarMult(dst, in, base) 16 | } 17 | 18 | // ScalarBaseMult sets dst to the product in*base where dst and base are the x 19 | // coordinates of group points, base is the standard generator and all values 20 | // are in little-endian form. 21 | func ScalarBaseMult(dst, in *[32]byte) { 22 | ScalarMult(dst, in, &basePoint) 23 | } 24 | -------------------------------------------------------------------------------- /cloud/Server.go: -------------------------------------------------------------------------------- 1 | package cloud 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type Server struct { 8 | PrivateIp string `json:"privateIp,omitempty"` 9 | ImageId string `json:"imageId,omitempty"` 10 | BackupsEnabled bool `json:"backupsEnabled,omitempty"` 11 | Description string `json:"description,omitempty"` 12 | SpecId string `json:"specId,omitempty"` 13 | PublicIp string `json:"publicIp,omitempty"` 14 | DataCenterId string `json:"dataCenterId,omitempty"` 15 | ModifiedAt time.Time `json:"modifiedAt,omitempty"` 16 | Status string `json:"status,omitempty"` 17 | BackupScheduleId string `json:"backupScheduleId,omitempty"` 18 | CreatedAt time.Time `json:"createdAt,omitempty"` 19 | ZoneId string `json:"zoneId,omitempty"` 20 | Hostname string `json:"hostname,omitempty"` 21 | Username string `json:"username,omitempty"` 22 | SshKeyId string `json:"sshKeyId,omitempty"` 23 | TaskState string `json:"taskState,omitempty"` 24 | ServerId string `json:"serverId,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /scripts/integration-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Install BATS 4 | cd $HOME 5 | if [ ! -d 'bats' ]; then 6 | echo "Installing BATS - bash automated testing system" 7 | git clone https://github.com/sstephenson/bats.git $HOME/bats 8 | cd $HOME/bats 9 | sudo ./install.sh /usr/local/ 10 | fi 11 | 12 | echo "Initializing go projects" 13 | /usr/local/go/bin/go get github.com/docker/machine 14 | /usr/local/go/bin/go get -u github.com/golang/lint/golint 15 | /usr/local/go/bin/go get -u github.com/dghubble/sling 16 | cd $GOPATH/src/github.com/docker/machine 17 | make build 18 | # docker-machine tests fail 19 | # make test 20 | 21 | if [ $? -ne 0 ]; then 22 | echo "Docker machine 'make test' failed" 23 | exit 1; 24 | fi 25 | 26 | go get -u github.com/godaddy/docker-machine-godaddy 27 | cd $GOPATH/src/github.com/godaddy/docker-machine-godaddy 28 | make build 29 | make install 30 | 31 | cd $GOPATH/src/github.com/docker/machine 32 | DRIVER=godaddy make test-integration test/integration/core/core-commands.bats 33 | if [ $? -ne 0 ]; then 34 | echo "Docker machine 'make test-integration' failed. See ./bats.log" 35 | exit 1; 36 | fi 37 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Bo Thompson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/dghubble/sling/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dalton Hubble 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/LICENSE.md: -------------------------------------------------------------------------------- 1 | objx - by Mat Ryer and Tyler Bunnell 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 Stretchr, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/tc_linux_cgo.go: -------------------------------------------------------------------------------- 1 | // +build linux,cgo 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // #include 11 | import "C" 12 | 13 | type Termios syscall.Termios 14 | 15 | // MakeRaw put the terminal connected to the given file descriptor into raw 16 | // mode and returns the previous state of the terminal so that it can be 17 | // restored. 18 | func MakeRaw(fd uintptr) (*State, error) { 19 | var oldState State 20 | if err := tcget(fd, &oldState.termios); err != 0 { 21 | return nil, err 22 | } 23 | 24 | newState := oldState.termios 25 | 26 | C.cfmakeraw((*C.struct_termios)(unsafe.Pointer(&newState))) 27 | if err := tcset(fd, &newState); err != 0 { 28 | return nil, err 29 | } 30 | return &oldState, nil 31 | } 32 | 33 | func tcget(fd uintptr, p *Termios) syscall.Errno { 34 | ret, err := C.tcgetattr(C.int(fd), (*C.struct_termios)(unsafe.Pointer(p))) 35 | if ret != 0 { 36 | return err.(syscall.Errno) 37 | } 38 | return 0 39 | } 40 | 41 | func tcset(fd uintptr, p *Termios) syscall.Errno { 42 | ret, err := C.tcsetattr(C.int(fd), C.TCSANOW, (*C.struct_termios)(unsafe.Pointer(p))) 43 | if ret != 0 { 44 | return err.(syscall.Errno) 45 | } 46 | return 0 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENCE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GODEP_BIN := $(GOPATH)/bin/godep 2 | GODEP := $(shell [ -x $(GODEP_BIN) ] && echo $(GODEP_BIN) || echo '') 3 | GO_LDFLAGS := -X $(shell go list ./).GitCommit=$(shell git rev-parse --short HEAD 2>/dev/null) 4 | 5 | version := "v1.0.0" 6 | name := "docker-machine-driver-godaddy" 7 | default: build 8 | 9 | clean: 10 | rm -f ./bin/$(name)* 11 | rm -f $(GOPATH)/bin/$(name)* 12 | 13 | compile: 14 | go build -ldflags "$(GO_LDFLAGS)" -i -o ./bin/$(name) ./bin 15 | 16 | print-success: 17 | @echo 18 | @echo "Plugin compiled successfully." 19 | @echo "To install it, run 'make install'" 20 | 21 | build: compile print-success 22 | 23 | install: 24 | cp bin/$(name) $(GOPATH)/bin/ 25 | 26 | release: 27 | rm -rf release 28 | mkdir release 29 | GOOS=linux GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o release/$(name)-Linux ./bin 30 | GOOS=darwin GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o release/$(name)-Darwin ./bin 31 | 32 | dep-save: 33 | $(if $(GODEP), , \ 34 | $(error Please install godep: go get github.com/tools/godep)) 35 | $(GODEP) save $(shell go list ./... | grep -v vendor/) 36 | 37 | dep-restore: 38 | $(if $(GODEP), , \ 39 | $(error Please install godep: go get github.com/tools/godep)) 40 | $(GODEP) restore -v 41 | 42 | .PHONY : build install release 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_linux.go: -------------------------------------------------------------------------------- 1 | // +build !cgo 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ( 11 | getTermios = syscall.TCGETS 12 | setTermios = syscall.TCSETS 13 | ) 14 | 15 | type Termios struct { 16 | Iflag uint32 17 | Oflag uint32 18 | Cflag uint32 19 | Lflag uint32 20 | Cc [20]byte 21 | Ispeed uint32 22 | Ospeed uint32 23 | } 24 | 25 | // MakeRaw put the terminal connected to the given file descriptor into raw 26 | // mode and returns the previous state of the terminal so that it can be 27 | // restored. 28 | func MakeRaw(fd uintptr) (*State, error) { 29 | var oldState State 30 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 31 | return nil, err 32 | } 33 | 34 | newState := oldState.termios 35 | 36 | newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) 37 | newState.Oflag &^= syscall.OPOST 38 | newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 39 | newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) 40 | newState.Cflag |= syscall.CS8 41 | 42 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { 43 | return nil, err 44 | } 45 | return &oldState, nil 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | new func(key []byte) hash.Hash 19 | } 20 | 21 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 22 | // a given size. 23 | type truncatingMAC struct { 24 | length int 25 | hmac hash.Hash 26 | } 27 | 28 | func (t truncatingMAC) Write(data []byte) (int, error) { 29 | return t.hmac.Write(data) 30 | } 31 | 32 | func (t truncatingMAC) Sum(in []byte) []byte { 33 | out := t.hmac.Sum(in) 34 | return out[:len(in)+t.length] 35 | } 36 | 37 | func (t truncatingMAC) Reset() { 38 | t.hmac.Reset() 39 | } 40 | 41 | func (t truncatingMAC) Size() int { 42 | return t.length 43 | } 44 | 45 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 46 | 47 | var macModes = map[string]*macMode{ 48 | "hmac-sha2-256": {32, func(key []byte) hash.Hash { 49 | return hmac.New(sha256.New, key) 50 | }}, 51 | "hmac-sha1": {20, func(key []byte) hash.Hash { 52 | return hmac.New(sha1.New, key) 53 | }}, 54 | "hmac-sha1-96": {20, func(key []byte) hash.Hash { 55 | return truncatingMAC{12, hmac.New(sha1.New, key)} 56 | }}, 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/mcnflag/flag.go: -------------------------------------------------------------------------------- 1 | package mcnflag 2 | 3 | import "fmt" 4 | 5 | type Flag interface { 6 | fmt.Stringer 7 | Default() interface{} 8 | } 9 | 10 | type StringFlag struct { 11 | Name string 12 | Usage string 13 | EnvVar string 14 | Value string 15 | } 16 | 17 | // TODO: Could this be done more succinctly using embedding? 18 | func (f StringFlag) String() string { 19 | return f.Name 20 | } 21 | 22 | func (f StringFlag) Default() interface{} { 23 | return f.Value 24 | } 25 | 26 | type StringSliceFlag struct { 27 | Name string 28 | Usage string 29 | EnvVar string 30 | Value []string 31 | } 32 | 33 | // TODO: Could this be done more succinctly using embedding? 34 | func (f StringSliceFlag) String() string { 35 | return f.Name 36 | } 37 | 38 | func (f StringSliceFlag) Default() interface{} { 39 | return f.Value 40 | } 41 | 42 | type IntFlag struct { 43 | Name string 44 | Usage string 45 | EnvVar string 46 | Value int 47 | } 48 | 49 | // TODO: Could this be done more succinctly using embedding? 50 | func (f IntFlag) String() string { 51 | return f.Name 52 | } 53 | 54 | func (f IntFlag) Default() interface{} { 55 | return f.Value 56 | } 57 | 58 | type BoolFlag struct { 59 | Name string 60 | Usage string 61 | EnvVar string 62 | } 63 | 64 | // TODO: Could this be done more succinctly using embedding? 65 | func (f BoolFlag) String() string { 66 | return f.Name 67 | } 68 | 69 | func (f BoolFlag) Default() interface{} { 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/google/go-querystring/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Google. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // Value provides methods for extracting interface{} data in various 9 | // types. 10 | type Value struct { 11 | // data contains the raw data being managed by this Value 12 | data interface{} 13 | } 14 | 15 | // Data returns the raw data contained by this Value 16 | func (v *Value) Data() interface{} { 17 | return v.data 18 | } 19 | 20 | // String returns the value always as a string 21 | func (v *Value) String() string { 22 | switch { 23 | case v.IsStr(): 24 | return v.Str() 25 | case v.IsBool(): 26 | return strconv.FormatBool(v.Bool()) 27 | case v.IsFloat32(): 28 | return strconv.FormatFloat(float64(v.Float32()), 'f', -1, 32) 29 | case v.IsFloat64(): 30 | return strconv.FormatFloat(v.Float64(), 'f', -1, 64) 31 | case v.IsInt(): 32 | return strconv.FormatInt(int64(v.Int()), 10) 33 | case v.IsInt(): 34 | return strconv.FormatInt(int64(v.Int()), 10) 35 | case v.IsInt8(): 36 | return strconv.FormatInt(int64(v.Int8()), 10) 37 | case v.IsInt16(): 38 | return strconv.FormatInt(int64(v.Int16()), 10) 39 | case v.IsInt32(): 40 | return strconv.FormatInt(int64(v.Int32()), 10) 41 | case v.IsInt64(): 42 | return strconv.FormatInt(v.Int64(), 10) 43 | case v.IsUint(): 44 | return strconv.FormatUint(uint64(v.Uint()), 10) 45 | case v.IsUint8(): 46 | return strconv.FormatUint(uint64(v.Uint8()), 10) 47 | case v.IsUint16(): 48 | return strconv.FormatUint(uint64(v.Uint16()), 10) 49 | case v.IsUint32(): 50 | return strconv.FormatUint(uint64(v.Uint32()), 10) 51 | case v.IsUint64(): 52 | return strconv.FormatUint(v.Uint64(), 10) 53 | } 54 | 55 | return fmt.Sprintf("%#v", v.Data()) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/plugin/register_driver.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "net/http" 7 | "net/rpc" 8 | "os" 9 | "time" 10 | 11 | "github.com/docker/machine/libmachine/drivers" 12 | "github.com/docker/machine/libmachine/drivers/plugin/localbinary" 13 | "github.com/docker/machine/libmachine/drivers/rpc" 14 | "github.com/docker/machine/libmachine/log" 15 | "github.com/docker/machine/libmachine/version" 16 | ) 17 | 18 | var ( 19 | heartbeatTimeout = 10 * time.Second 20 | ) 21 | 22 | func RegisterDriver(d drivers.Driver) { 23 | if os.Getenv(localbinary.PluginEnvKey) != localbinary.PluginEnvVal { 24 | fmt.Fprintf(os.Stderr, `This is a Docker Machine plugin binary. 25 | Plugin binaries are not intended to be invoked directly. 26 | Please use this plugin through the main 'docker-machine' binary. 27 | (API version: %d) 28 | `, version.APIVersion) 29 | os.Exit(1) 30 | } 31 | 32 | log.SetDebug(true) 33 | os.Setenv("MACHINE_DEBUG", "1") 34 | 35 | rpcd := rpcdriver.NewRPCServerDriver(d) 36 | rpc.RegisterName(rpcdriver.RPCServiceNameV0, rpcd) 37 | rpc.RegisterName(rpcdriver.RPCServiceNameV1, rpcd) 38 | rpc.HandleHTTP() 39 | 40 | listener, err := net.Listen("tcp", "127.0.0.1:0") 41 | if err != nil { 42 | fmt.Fprintf(os.Stderr, "Error loading RPC server: %s\n", err) 43 | os.Exit(1) 44 | } 45 | defer listener.Close() 46 | 47 | fmt.Println(listener.Addr()) 48 | 49 | go http.Serve(listener, nil) 50 | 51 | for { 52 | select { 53 | case <-rpcd.CloseCh: 54 | log.Debug("Closing plugin on server side") 55 | os.Exit(0) 56 | case <-rpcd.HeartbeatCh: 57 | continue 58 | case <-time.After(heartbeatTimeout): 59 | // TODO: Add heartbeat retry logic 60 | os.Exit(1) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/mock/doc.go: -------------------------------------------------------------------------------- 1 | // Package mock provides a system by which it is possible to mock your objects 2 | // and verify calls are happening as expected. 3 | // 4 | // Example Usage 5 | // 6 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually 7 | // embedded into a test object as shown below: 8 | // 9 | // type MyTestObject struct { 10 | // // add a Mock object instance 11 | // mock.Mock 12 | // 13 | // // other fields go here as normal 14 | // } 15 | // 16 | // When implementing the methods of an interface, you wire your functions up 17 | // to call the Mock.Called(args...) method, and return the appropriate values. 18 | // 19 | // For example, to mock a method that saves the name and age of a person and returns 20 | // the year of their birth or an error, you might write this: 21 | // 22 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { 23 | // args := o.Called(firstname, lastname, age) 24 | // return args.Int(0), args.Error(1) 25 | // } 26 | // 27 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument 28 | // index position. Given this argument list: 29 | // 30 | // (12, true, "Something") 31 | // 32 | // You could read them out strongly typed like this: 33 | // 34 | // args.Int(0) 35 | // args.Bool(1) 36 | // args.String(2) 37 | // 38 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: 39 | // 40 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) 41 | // 42 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those 43 | // cases you should check for nil first. 44 | package mock 45 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | "regexp" 6 | ) 7 | 8 | const redactedText = "" 9 | 10 | var ( 11 | logger = NewFmtMachineLogger() 12 | 13 | // (?s) enables '.' to match '\n' -- see https://golang.org/pkg/regexp/syntax/ 14 | certRegex = regexp.MustCompile("(?s)-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----") 15 | keyRegex = regexp.MustCompile("(?s)-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----") 16 | ) 17 | 18 | func stripSecrets(original []string) []string { 19 | stripped := []string{} 20 | for _, line := range original { 21 | line = certRegex.ReplaceAllString(line, redactedText) 22 | line = keyRegex.ReplaceAllString(line, redactedText) 23 | stripped = append(stripped, line) 24 | } 25 | return stripped 26 | } 27 | 28 | func Debug(args ...interface{}) { 29 | logger.Debug(args...) 30 | } 31 | 32 | func Debugf(fmtString string, args ...interface{}) { 33 | logger.Debugf(fmtString, args...) 34 | } 35 | 36 | func Error(args ...interface{}) { 37 | logger.Error(args...) 38 | } 39 | 40 | func Errorf(fmtString string, args ...interface{}) { 41 | logger.Errorf(fmtString, args...) 42 | } 43 | 44 | func Info(args ...interface{}) { 45 | logger.Info(args...) 46 | } 47 | 48 | func Infof(fmtString string, args ...interface{}) { 49 | logger.Infof(fmtString, args...) 50 | } 51 | 52 | func Warn(args ...interface{}) { 53 | logger.Warn(args...) 54 | } 55 | 56 | func Warnf(fmtString string, args ...interface{}) { 57 | logger.Warnf(fmtString, args...) 58 | } 59 | 60 | func SetDebug(debug bool) { 61 | logger.SetDebug(debug) 62 | } 63 | 64 | func SetOutWriter(out io.Writer) { 65 | logger.SetOutWriter(out) 66 | } 67 | 68 | func SetErrWriter(err io.Writer) { 69 | logger.SetErrWriter(err) 70 | } 71 | 72 | func History() []string { 73 | return stripSecrets(logger.History()) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_darwin.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | 12 | IGNBRK = syscall.IGNBRK 13 | PARMRK = syscall.PARMRK 14 | INLCR = syscall.INLCR 15 | IGNCR = syscall.IGNCR 16 | ECHONL = syscall.ECHONL 17 | CSIZE = syscall.CSIZE 18 | ICRNL = syscall.ICRNL 19 | ISTRIP = syscall.ISTRIP 20 | PARENB = syscall.PARENB 21 | ECHO = syscall.ECHO 22 | ICANON = syscall.ICANON 23 | ISIG = syscall.ISIG 24 | IXON = syscall.IXON 25 | BRKINT = syscall.BRKINT 26 | INPCK = syscall.INPCK 27 | OPOST = syscall.OPOST 28 | CS8 = syscall.CS8 29 | IEXTEN = syscall.IEXTEN 30 | ) 31 | 32 | type Termios struct { 33 | Iflag uint64 34 | Oflag uint64 35 | Cflag uint64 36 | Lflag uint64 37 | Cc [20]byte 38 | Ispeed uint64 39 | Ospeed uint64 40 | } 41 | 42 | // MakeRaw put the terminal connected to the given file descriptor into raw 43 | // mode and returns the previous state of the terminal so that it can be 44 | // restored. 45 | func MakeRaw(fd uintptr) (*State, error) { 46 | var oldState State 47 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 48 | return nil, err 49 | } 50 | 51 | newState := oldState.termios 52 | newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) 53 | newState.Oflag &^= OPOST 54 | newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) 55 | newState.Cflag &^= (CSIZE | PARENB) 56 | newState.Cflag |= CS8 57 | newState.Cc[syscall.VMIN] = 1 58 | newState.Cc[syscall.VTIME] = 0 59 | 60 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 61 | return nil, err 62 | } 63 | 64 | return &oldState, nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_freebsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | 12 | IGNBRK = syscall.IGNBRK 13 | PARMRK = syscall.PARMRK 14 | INLCR = syscall.INLCR 15 | IGNCR = syscall.IGNCR 16 | ECHONL = syscall.ECHONL 17 | CSIZE = syscall.CSIZE 18 | ICRNL = syscall.ICRNL 19 | ISTRIP = syscall.ISTRIP 20 | PARENB = syscall.PARENB 21 | ECHO = syscall.ECHO 22 | ICANON = syscall.ICANON 23 | ISIG = syscall.ISIG 24 | IXON = syscall.IXON 25 | BRKINT = syscall.BRKINT 26 | INPCK = syscall.INPCK 27 | OPOST = syscall.OPOST 28 | CS8 = syscall.CS8 29 | IEXTEN = syscall.IEXTEN 30 | ) 31 | 32 | type Termios struct { 33 | Iflag uint32 34 | Oflag uint32 35 | Cflag uint32 36 | Lflag uint32 37 | Cc [20]byte 38 | Ispeed uint32 39 | Ospeed uint32 40 | } 41 | 42 | // MakeRaw put the terminal connected to the given file descriptor into raw 43 | // mode and returns the previous state of the terminal so that it can be 44 | // restored. 45 | func MakeRaw(fd uintptr) (*State, error) { 46 | var oldState State 47 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 48 | return nil, err 49 | } 50 | 51 | newState := oldState.termios 52 | newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) 53 | newState.Oflag &^= OPOST 54 | newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) 55 | newState.Cflag &^= (CSIZE | PARENB) 56 | newState.Cflag |= CS8 57 | newState.Cc[syscall.VMIN] = 1 58 | newState.Cc[syscall.VTIME] = 0 59 | 60 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 61 | return nil, err 62 | } 63 | 64 | return &oldState, nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/cswap_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func cswap(inout *[5]uint64, v uint64) 11 | TEXT ·cswap(SB),7,$0 12 | MOVQ inout+0(FP),DI 13 | MOVQ v+8(FP),SI 14 | 15 | CMPQ SI,$1 16 | MOVQ 0(DI),SI 17 | MOVQ 80(DI),DX 18 | MOVQ 8(DI),CX 19 | MOVQ 88(DI),R8 20 | MOVQ SI,R9 21 | CMOVQEQ DX,SI 22 | CMOVQEQ R9,DX 23 | MOVQ CX,R9 24 | CMOVQEQ R8,CX 25 | CMOVQEQ R9,R8 26 | MOVQ SI,0(DI) 27 | MOVQ DX,80(DI) 28 | MOVQ CX,8(DI) 29 | MOVQ R8,88(DI) 30 | MOVQ 16(DI),SI 31 | MOVQ 96(DI),DX 32 | MOVQ 24(DI),CX 33 | MOVQ 104(DI),R8 34 | MOVQ SI,R9 35 | CMOVQEQ DX,SI 36 | CMOVQEQ R9,DX 37 | MOVQ CX,R9 38 | CMOVQEQ R8,CX 39 | CMOVQEQ R9,R8 40 | MOVQ SI,16(DI) 41 | MOVQ DX,96(DI) 42 | MOVQ CX,24(DI) 43 | MOVQ R8,104(DI) 44 | MOVQ 32(DI),SI 45 | MOVQ 112(DI),DX 46 | MOVQ 40(DI),CX 47 | MOVQ 120(DI),R8 48 | MOVQ SI,R9 49 | CMOVQEQ DX,SI 50 | CMOVQEQ R9,DX 51 | MOVQ CX,R9 52 | CMOVQEQ R8,CX 53 | CMOVQEQ R9,R8 54 | MOVQ SI,32(DI) 55 | MOVQ DX,112(DI) 56 | MOVQ CX,40(DI) 57 | MOVQ R8,120(DI) 58 | MOVQ 48(DI),SI 59 | MOVQ 128(DI),DX 60 | MOVQ 56(DI),CX 61 | MOVQ 136(DI),R8 62 | MOVQ SI,R9 63 | CMOVQEQ DX,SI 64 | CMOVQEQ R9,DX 65 | MOVQ CX,R9 66 | CMOVQEQ R8,CX 67 | CMOVQEQ R9,R8 68 | MOVQ SI,48(DI) 69 | MOVQ DX,128(DI) 70 | MOVQ CX,56(DI) 71 | MOVQ R8,136(DI) 72 | MOVQ 64(DI),SI 73 | MOVQ 144(DI),DX 74 | MOVQ 72(DI),CX 75 | MOVQ 152(DI),R8 76 | MOVQ SI,R9 77 | CMOVQEQ DX,SI 78 | CMOVQEQ R9,DX 79 | MOVQ CX,R9 80 | CMOVQEQ R8,CX 81 | CMOVQEQ R9,R8 82 | MOVQ SI,64(DI) 83 | MOVQ DX,144(DI) 84 | MOVQ CX,72(DI) 85 | MOVQ R8,152(DI) 86 | MOVQ DI,AX 87 | MOVQ SI,DX 88 | RET 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/freeze_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func freeze(inout *[5]uint64) 11 | TEXT ·freeze(SB),7,$96-8 12 | MOVQ inout+0(FP), DI 13 | 14 | MOVQ SP,R11 15 | MOVQ $31,CX 16 | NOTQ CX 17 | ANDQ CX,SP 18 | ADDQ $32,SP 19 | 20 | MOVQ R11,0(SP) 21 | MOVQ R12,8(SP) 22 | MOVQ R13,16(SP) 23 | MOVQ R14,24(SP) 24 | MOVQ R15,32(SP) 25 | MOVQ BX,40(SP) 26 | MOVQ BP,48(SP) 27 | MOVQ 0(DI),SI 28 | MOVQ 8(DI),DX 29 | MOVQ 16(DI),CX 30 | MOVQ 24(DI),R8 31 | MOVQ 32(DI),R9 32 | MOVQ ·REDMASK51(SB),AX 33 | MOVQ AX,R10 34 | SUBQ $18,R10 35 | MOVQ $3,R11 36 | REDUCELOOP: 37 | MOVQ SI,R12 38 | SHRQ $51,R12 39 | ANDQ AX,SI 40 | ADDQ R12,DX 41 | MOVQ DX,R12 42 | SHRQ $51,R12 43 | ANDQ AX,DX 44 | ADDQ R12,CX 45 | MOVQ CX,R12 46 | SHRQ $51,R12 47 | ANDQ AX,CX 48 | ADDQ R12,R8 49 | MOVQ R8,R12 50 | SHRQ $51,R12 51 | ANDQ AX,R8 52 | ADDQ R12,R9 53 | MOVQ R9,R12 54 | SHRQ $51,R12 55 | ANDQ AX,R9 56 | IMUL3Q $19,R12,R12 57 | ADDQ R12,SI 58 | SUBQ $1,R11 59 | JA REDUCELOOP 60 | MOVQ $1,R12 61 | CMPQ R10,SI 62 | CMOVQLT R11,R12 63 | CMPQ AX,DX 64 | CMOVQNE R11,R12 65 | CMPQ AX,CX 66 | CMOVQNE R11,R12 67 | CMPQ AX,R8 68 | CMOVQNE R11,R12 69 | CMPQ AX,R9 70 | CMOVQNE R11,R12 71 | NEGQ R12 72 | ANDQ R12,AX 73 | ANDQ R12,R10 74 | SUBQ R10,SI 75 | SUBQ AX,DX 76 | SUBQ AX,CX 77 | SUBQ AX,R8 78 | SUBQ AX,R9 79 | MOVQ SI,0(DI) 80 | MOVQ DX,8(DI) 81 | MOVQ CX,16(DI) 82 | MOVQ R8,24(DI) 83 | MOVQ R9,32(DI) 84 | MOVQ 0(SP),R11 85 | MOVQ 8(SP),R12 86 | MOVQ 16(SP),R13 87 | MOVQ 24(SP),R14 88 | MOVQ 32(SP),R15 89 | MOVQ 40(SP),BX 90 | MOVQ 48(SP),BP 91 | MOVQ R11,SP 92 | MOVQ DI,AX 93 | MOVQ SI,DX 94 | RET 95 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/utils.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/docker/machine/libmachine/log" 7 | "github.com/docker/machine/libmachine/mcnutils" 8 | "github.com/docker/machine/libmachine/ssh" 9 | ) 10 | 11 | func GetSSHClientFromDriver(d Driver) (ssh.Client, error) { 12 | address, err := d.GetSSHHostname() 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | port, err := d.GetSSHPort() 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | var auth *ssh.Auth 23 | if d.GetSSHKeyPath() == "" { 24 | auth = &ssh.Auth{} 25 | } else { 26 | auth = &ssh.Auth{ 27 | Keys: []string{d.GetSSHKeyPath()}, 28 | } 29 | } 30 | 31 | client, err := ssh.NewClient(d.GetSSHUsername(), address, port, auth) 32 | return client, err 33 | 34 | } 35 | 36 | func RunSSHCommandFromDriver(d Driver, command string) (string, error) { 37 | client, err := GetSSHClientFromDriver(d) 38 | if err != nil { 39 | return "", err 40 | } 41 | 42 | log.Debugf("About to run SSH command:\n%s", command) 43 | 44 | output, err := client.Output(command) 45 | log.Debugf("SSH cmd err, output: %v: %s", err, output) 46 | if err != nil { 47 | return "", fmt.Errorf(`Something went wrong running an SSH command! 48 | command : %s 49 | err : %v 50 | output : %s 51 | `, command, err, output) 52 | } 53 | 54 | return output, nil 55 | } 56 | 57 | func sshAvailableFunc(d Driver) func() bool { 58 | return func() bool { 59 | log.Debug("Getting to WaitForSSH function...") 60 | if _, err := RunSSHCommandFromDriver(d, "exit 0"); err != nil { 61 | log.Debugf("Error getting ssh command 'exit 0' : %s", err) 62 | return false 63 | } 64 | return true 65 | } 66 | } 67 | 68 | func WaitForSSH(d Driver) error { 69 | // Try to dial SSH for 30 seconds before timing out. 70 | if err := mcnutils.WaitFor(sshAvailableFunc(d)); err != nil { 71 | return fmt.Errorf("Too many retries waiting for SSH to be available. Last error: %s", err) 72 | } 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/check.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import "github.com/docker/machine/libmachine/mcnflag" 4 | 5 | // CheckDriverOptions implements DriverOptions and is used to validate flag parsing 6 | type CheckDriverOptions struct { 7 | FlagsValues map[string]interface{} 8 | CreateFlags []mcnflag.Flag 9 | InvalidFlags []string 10 | } 11 | 12 | func (o *CheckDriverOptions) String(key string) string { 13 | for _, flag := range o.CreateFlags { 14 | if flag.String() == key { 15 | f, ok := flag.(mcnflag.StringFlag) 16 | if !ok { 17 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 18 | } 19 | 20 | value, present := o.FlagsValues[key].(string) 21 | if present { 22 | return value 23 | } 24 | return f.Value 25 | } 26 | } 27 | 28 | return "" 29 | } 30 | 31 | func (o *CheckDriverOptions) StringSlice(key string) []string { 32 | for _, flag := range o.CreateFlags { 33 | if flag.String() == key { 34 | f, ok := flag.(mcnflag.StringSliceFlag) 35 | if !ok { 36 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 37 | } 38 | 39 | value, present := o.FlagsValues[key].([]string) 40 | if present { 41 | return value 42 | } 43 | return f.Value 44 | } 45 | } 46 | 47 | return nil 48 | } 49 | 50 | func (o *CheckDriverOptions) Int(key string) int { 51 | for _, flag := range o.CreateFlags { 52 | if flag.String() == key { 53 | f, ok := flag.(mcnflag.IntFlag) 54 | if !ok { 55 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 56 | } 57 | 58 | value, present := o.FlagsValues[key].(int) 59 | if present { 60 | return value 61 | } 62 | return f.Value 63 | } 64 | } 65 | 66 | return 0 67 | } 68 | 69 | func (o *CheckDriverOptions) Bool(key string) bool { 70 | for _, flag := range o.CreateFlags { 71 | if flag.String() == key { 72 | _, ok := flag.(mcnflag.BoolFlag) 73 | if !ok { 74 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 75 | } 76 | } 77 | } 78 | 79 | value, present := o.FlagsValues[key].(bool) 80 | if present { 81 | return value 82 | } 83 | return false 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/fmt_machine_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | ) 8 | 9 | type FmtMachineLogger struct { 10 | outWriter io.Writer 11 | errWriter io.Writer 12 | debug bool 13 | history *HistoryRecorder 14 | } 15 | 16 | // NewFmtMachineLogger creates a MachineLogger implementation used by the drivers 17 | func NewFmtMachineLogger() MachineLogger { 18 | return &FmtMachineLogger{ 19 | outWriter: os.Stdout, 20 | errWriter: os.Stderr, 21 | debug: false, 22 | history: NewHistoryRecorder(), 23 | } 24 | } 25 | 26 | func (ml *FmtMachineLogger) SetDebug(debug bool) { 27 | ml.debug = debug 28 | } 29 | 30 | func (ml *FmtMachineLogger) SetOutWriter(out io.Writer) { 31 | ml.outWriter = out 32 | } 33 | 34 | func (ml *FmtMachineLogger) SetErrWriter(err io.Writer) { 35 | ml.errWriter = err 36 | } 37 | 38 | func (ml *FmtMachineLogger) Debug(args ...interface{}) { 39 | ml.history.Record(args...) 40 | if ml.debug { 41 | fmt.Fprintln(ml.errWriter, args...) 42 | } 43 | } 44 | 45 | func (ml *FmtMachineLogger) Debugf(fmtString string, args ...interface{}) { 46 | ml.history.Recordf(fmtString, args...) 47 | if ml.debug { 48 | fmt.Fprintf(ml.errWriter, fmtString+"\n", args...) 49 | } 50 | } 51 | 52 | func (ml *FmtMachineLogger) Error(args ...interface{}) { 53 | ml.history.Record(args...) 54 | fmt.Fprintln(ml.errWriter, args...) 55 | } 56 | 57 | func (ml *FmtMachineLogger) Errorf(fmtString string, args ...interface{}) { 58 | ml.history.Recordf(fmtString, args...) 59 | fmt.Fprintf(ml.errWriter, fmtString+"\n", args...) 60 | } 61 | 62 | func (ml *FmtMachineLogger) Info(args ...interface{}) { 63 | ml.history.Record(args...) 64 | fmt.Fprintln(ml.outWriter, args...) 65 | } 66 | 67 | func (ml *FmtMachineLogger) Infof(fmtString string, args ...interface{}) { 68 | ml.history.Recordf(fmtString, args...) 69 | fmt.Fprintf(ml.outWriter, fmtString+"\n", args...) 70 | } 71 | 72 | func (ml *FmtMachineLogger) Warn(args ...interface{}) { 73 | ml.history.Record(args...) 74 | fmt.Fprintln(ml.outWriter, args...) 75 | } 76 | 77 | func (ml *FmtMachineLogger) Warnf(fmtString string, args ...interface{}) { 78 | ml.history.Recordf(fmtString, args...) 79 | fmt.Fprintf(ml.outWriter, fmtString+"\n", args...) 80 | } 81 | 82 | func (ml *FmtMachineLogger) History() []string { 83 | return ml.history.records 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/console_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ( 11 | // Consts for Get/SetConsoleMode function 12 | // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx 13 | ENABLE_ECHO_INPUT = 0x0004 14 | ENABLE_INSERT_MODE = 0x0020 15 | ENABLE_LINE_INPUT = 0x0002 16 | ENABLE_MOUSE_INPUT = 0x0010 17 | ENABLE_PROCESSED_INPUT = 0x0001 18 | ENABLE_QUICK_EDIT_MODE = 0x0040 19 | ENABLE_WINDOW_INPUT = 0x0008 20 | // If parameter is a screen buffer handle, additional values 21 | ENABLE_PROCESSED_OUTPUT = 0x0001 22 | ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002 23 | ) 24 | 25 | var kernel32DLL = syscall.NewLazyDLL("kernel32.dll") 26 | 27 | var ( 28 | setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode") 29 | getConsoleScreenBufferInfoProc = kernel32DLL.NewProc("GetConsoleScreenBufferInfo") 30 | ) 31 | 32 | func GetConsoleMode(fileDesc uintptr) (uint32, error) { 33 | var mode uint32 34 | err := syscall.GetConsoleMode(syscall.Handle(fileDesc), &mode) 35 | return mode, err 36 | } 37 | 38 | func SetConsoleMode(fileDesc uintptr, mode uint32) error { 39 | r, _, err := setConsoleModeProc.Call(fileDesc, uintptr(mode), 0) 40 | if r == 0 { 41 | if err != nil { 42 | return err 43 | } 44 | return syscall.EINVAL 45 | } 46 | return nil 47 | } 48 | 49 | // types for calling GetConsoleScreenBufferInfo 50 | // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx 51 | type ( 52 | SHORT int16 53 | 54 | SMALL_RECT struct { 55 | Left SHORT 56 | Top SHORT 57 | Right SHORT 58 | Bottom SHORT 59 | } 60 | 61 | COORD struct { 62 | X SHORT 63 | Y SHORT 64 | } 65 | 66 | WORD uint16 67 | 68 | CONSOLE_SCREEN_BUFFER_INFO struct { 69 | dwSize COORD 70 | dwCursorPosition COORD 71 | wAttributes WORD 72 | srWindow SMALL_RECT 73 | dwMaximumWindowSize COORD 74 | } 75 | ) 76 | 77 | func GetConsoleScreenBufferInfo(fileDesc uintptr) (*CONSOLE_SCREEN_BUFFER_INFO, error) { 78 | var info CONSOLE_SCREEN_BUFFER_INFO 79 | r, _, err := getConsoleScreenBufferInfoProc.Call(uintptr(fileDesc), uintptr(unsafe.Pointer(&info)), 0) 80 | if r == 0 { 81 | if err != nil { 82 | return nil, err 83 | } 84 | return nil, syscall.EINVAL 85 | } 86 | return &info, nil 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/notsupported.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/docker/machine/libmachine/mcnflag" 7 | "github.com/docker/machine/libmachine/state" 8 | ) 9 | 10 | type DriverNotSupported struct { 11 | *BaseDriver 12 | Name string 13 | } 14 | 15 | type NotSupported struct { 16 | DriverName string 17 | } 18 | 19 | func (e NotSupported) Error() string { 20 | return fmt.Sprintf("Driver %q not supported on this platform.", e.DriverName) 21 | } 22 | 23 | // NewDriverNotSupported creates a placeholder Driver that replaces 24 | // a driver that is not supported on a given platform. eg fusion on linux. 25 | func NewDriverNotSupported(driverName, hostName, storePath string) Driver { 26 | return &DriverNotSupported{ 27 | BaseDriver: &BaseDriver{ 28 | MachineName: hostName, 29 | StorePath: storePath, 30 | }, 31 | Name: driverName, 32 | } 33 | } 34 | 35 | func (d *DriverNotSupported) DriverName() string { 36 | return d.Name 37 | } 38 | 39 | func (d *DriverNotSupported) PreCreateCheck() error { 40 | return NotSupported{d.DriverName()} 41 | } 42 | 43 | func (d *DriverNotSupported) GetCreateFlags() []mcnflag.Flag { 44 | return nil 45 | } 46 | 47 | func (d *DriverNotSupported) SetConfigFromFlags(flags DriverOptions) error { 48 | return NotSupported{d.DriverName()} 49 | } 50 | 51 | func (d *DriverNotSupported) GetURL() (string, error) { 52 | return "", NotSupported{d.DriverName()} 53 | } 54 | 55 | func (d *DriverNotSupported) GetSSHHostname() (string, error) { 56 | return "", NotSupported{d.DriverName()} 57 | } 58 | 59 | func (d *DriverNotSupported) GetState() (state.State, error) { 60 | return state.Error, NotSupported{d.DriverName()} 61 | } 62 | 63 | func (d *DriverNotSupported) Create() error { 64 | return NotSupported{d.DriverName()} 65 | } 66 | 67 | func (d *DriverNotSupported) Remove() error { 68 | return NotSupported{d.DriverName()} 69 | } 70 | 71 | func (d *DriverNotSupported) Start() error { 72 | return NotSupported{d.DriverName()} 73 | } 74 | 75 | func (d *DriverNotSupported) Stop() error { 76 | return NotSupported{d.DriverName()} 77 | } 78 | 79 | func (d *DriverNotSupported) Restart() error { 80 | return NotSupported{d.DriverName()} 81 | } 82 | 83 | func (d *DriverNotSupported) Kill() error { 84 | return NotSupported{d.DriverName()} 85 | } 86 | 87 | func (d *DriverNotSupported) Upgrade() error { 88 | return NotSupported{d.DriverName()} 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/mutations.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Exclude returns a new Map with the keys in the specified []string 4 | // excluded. 5 | func (d Map) Exclude(exclude []string) Map { 6 | 7 | excluded := make(Map) 8 | for k, v := range d { 9 | var shouldInclude bool = true 10 | for _, toExclude := range exclude { 11 | if k == toExclude { 12 | shouldInclude = false 13 | break 14 | } 15 | } 16 | if shouldInclude { 17 | excluded[k] = v 18 | } 19 | } 20 | 21 | return excluded 22 | } 23 | 24 | // Copy creates a shallow copy of the Obj. 25 | func (m Map) Copy() Map { 26 | copied := make(map[string]interface{}) 27 | for k, v := range m { 28 | copied[k] = v 29 | } 30 | return New(copied) 31 | } 32 | 33 | // Merge blends the specified map with a copy of this map and returns the result. 34 | // 35 | // Keys that appear in both will be selected from the specified map. 36 | // This method requires that the wrapped object be a map[string]interface{} 37 | func (m Map) Merge(merge Map) Map { 38 | return m.Copy().MergeHere(merge) 39 | } 40 | 41 | // Merge blends the specified map with this map and returns the current map. 42 | // 43 | // Keys that appear in both will be selected from the specified map. The original map 44 | // will be modified. This method requires that 45 | // the wrapped object be a map[string]interface{} 46 | func (m Map) MergeHere(merge Map) Map { 47 | 48 | for k, v := range merge { 49 | m[k] = v 50 | } 51 | 52 | return m 53 | 54 | } 55 | 56 | // Transform builds a new Obj giving the transformer a chance 57 | // to change the keys and values as it goes. This method requires that 58 | // the wrapped object be a map[string]interface{} 59 | func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map { 60 | newMap := make(map[string]interface{}) 61 | for k, v := range m { 62 | modifiedKey, modifiedVal := transformer(k, v) 63 | newMap[modifiedKey] = modifiedVal 64 | } 65 | return New(newMap) 66 | } 67 | 68 | // TransformKeys builds a new map using the specified key mapping. 69 | // 70 | // Unspecified keys will be unaltered. 71 | // This method requires that the wrapped object be a map[string]interface{} 72 | func (m Map) TransformKeys(mapping map[string]string) Map { 73 | return m.Transform(func(key string, value interface{}) (string, interface{}) { 74 | 75 | if newKey, ok := mapping[key]; ok { 76 | return newKey, value 77 | } 78 | 79 | return key, value 80 | }) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/dghubble/sling/CHANGES.md: -------------------------------------------------------------------------------- 1 | # Sling Changelog 2 | 3 | Notable changes between releases. 4 | 5 | ## latest 6 | 7 | * Added Sling `Body` setter to set an `io.Reader` on the Request 8 | 9 | ## v1.0.0 (2015-05-23) 10 | 11 | * Added support for receiving and decoding error JSON structs 12 | * Renamed Sling `JsonBody` setter to `BodyJSON` (breaking) 13 | * Renamed Sling `BodyStruct` setter to `BodyForm` (breaking) 14 | * Renamed Sling fields `httpClient`, `method`, `rawURL`, and `header` to be internal (breaking) 15 | * Changed `Do` and `Receive` to skip response JSON decoding if "application/json" Content-Type is missing 16 | * Changed `Sling.Receive(v interface{})` to `Sling.Receive(successV, failureV interface{})` (breaking) 17 | * Previously `Receive` attempted to decode the response Body in all cases 18 | * Updated `Receive` will decode the response Body into successV for 2XX responses or decode the Body into failureV for other status codes. Pass a nil `successV` or `failureV` to skip JSON decoding into that value. 19 | * To upgrade, pass nil for the `failureV` argument or consider defining a JSON tagged struct appropriate for the API endpoint. (e.g. `s.Receive(&issue, nil)`, `s.Receive(&issue, &githubError)`) 20 | * To retain the old behavior, duplicate the first argument (e.g. s.Receive(&tweet, &tweet)) 21 | * Changed `Sling.Do(http.Request, v interface{})` to `Sling.Do(http.Request, successV, failureV interface{})` (breaking) 22 | * See the changelog entry about `Receive`, the upgrade path is the same. 23 | * Removed HEAD, GET, POST, PUT, PATCH, DELETE constants, no reason to export them (breaking) 24 | 25 | ## v0.4.0 (2015-04-26) 26 | 27 | * Improved golint compliance 28 | * Fixed typos and test printouts 29 | 30 | ## v0.3.0 (2015-04-21) 31 | 32 | * Added BodyStruct method for setting a url encoded form body on the Request 33 | * Added Add and Set methods for adding or setting Request Headers 34 | * Added JsonBody method for setting JSON Request Body 35 | * Improved examples and documentation 36 | 37 | ## v0.2.0 (2015-04-05) 38 | 39 | * Added http.Client setter 40 | * Added Sling.New() method to return a copy of a Sling 41 | * Added Base setter and Path extension support 42 | * Added method setters (Get, Post, Put, Patch, Delete, Head) 43 | * Added support for encoding URL Query parameters 44 | * Added example tiny Github API 45 | * Changed v0.1.0 method signatures and names (breaking) 46 | * Removed Go 1.0 support 47 | 48 | ## v0.1.0 (2015-04-01) 49 | 50 | * Support decoding JSON responses. 51 | 52 | 53 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/term.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package term 4 | 5 | import ( 6 | "errors" 7 | "os" 8 | "os/signal" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | var ( 14 | ErrInvalidState = errors.New("Invalid terminal state") 15 | ) 16 | 17 | type State struct { 18 | termios Termios 19 | } 20 | 21 | type Winsize struct { 22 | Height uint16 23 | Width uint16 24 | x uint16 25 | y uint16 26 | } 27 | 28 | func GetWinsize(fd uintptr) (*Winsize, error) { 29 | ws := &Winsize{} 30 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) 31 | // Skipp errno = 0 32 | if err == 0 { 33 | return ws, nil 34 | } 35 | return ws, err 36 | } 37 | 38 | func SetWinsize(fd uintptr, ws *Winsize) error { 39 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) 40 | // Skipp errno = 0 41 | if err == 0 { 42 | return nil 43 | } 44 | return err 45 | } 46 | 47 | // IsTerminal returns true if the given file descriptor is a terminal. 48 | func IsTerminal(fd uintptr) bool { 49 | var termios Termios 50 | return tcget(fd, &termios) == 0 51 | } 52 | 53 | // Restore restores the terminal connected to the given file descriptor to a 54 | // previous state. 55 | func RestoreTerminal(fd uintptr, state *State) error { 56 | if state == nil { 57 | return ErrInvalidState 58 | } 59 | if err := tcset(fd, &state.termios); err != 0 { 60 | return err 61 | } 62 | return nil 63 | } 64 | 65 | func SaveState(fd uintptr) (*State, error) { 66 | var oldState State 67 | if err := tcget(fd, &oldState.termios); err != 0 { 68 | return nil, err 69 | } 70 | 71 | return &oldState, nil 72 | } 73 | 74 | func DisableEcho(fd uintptr, state *State) error { 75 | newState := state.termios 76 | newState.Lflag &^= syscall.ECHO 77 | 78 | if err := tcset(fd, &newState); err != 0 { 79 | return err 80 | } 81 | handleInterrupt(fd, state) 82 | return nil 83 | } 84 | 85 | func SetRawTerminal(fd uintptr) (*State, error) { 86 | oldState, err := MakeRaw(fd) 87 | if err != nil { 88 | return nil, err 89 | } 90 | handleInterrupt(fd, oldState) 91 | return oldState, err 92 | } 93 | 94 | func handleInterrupt(fd uintptr, state *State) { 95 | sigchan := make(chan os.Signal, 1) 96 | signal.Notify(sigchan, os.Interrupt) 97 | 98 | go func() { 99 | _ = <-sigchan 100 | RestoreTerminal(fd, state) 101 | os.Exit(0) 102 | }() 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "io" 9 | "sync" 10 | ) 11 | 12 | // buffer provides a linked list buffer for data exchange 13 | // between producer and consumer. Theoretically the buffer is 14 | // of unlimited capacity as it does no allocation of its own. 15 | type buffer struct { 16 | // protects concurrent access to head, tail and closed 17 | *sync.Cond 18 | 19 | head *element // the buffer that will be read first 20 | tail *element // the buffer that will be read last 21 | 22 | closed bool 23 | } 24 | 25 | // An element represents a single link in a linked list. 26 | type element struct { 27 | buf []byte 28 | next *element 29 | } 30 | 31 | // newBuffer returns an empty buffer that is not closed. 32 | func newBuffer() *buffer { 33 | e := new(element) 34 | b := &buffer{ 35 | Cond: newCond(), 36 | head: e, 37 | tail: e, 38 | } 39 | return b 40 | } 41 | 42 | // write makes buf available for Read to receive. 43 | // buf must not be modified after the call to write. 44 | func (b *buffer) write(buf []byte) { 45 | b.Cond.L.Lock() 46 | e := &element{buf: buf} 47 | b.tail.next = e 48 | b.tail = e 49 | b.Cond.Signal() 50 | b.Cond.L.Unlock() 51 | } 52 | 53 | // eof closes the buffer. Reads from the buffer once all 54 | // the data has been consumed will receive os.EOF. 55 | func (b *buffer) eof() error { 56 | b.Cond.L.Lock() 57 | b.closed = true 58 | b.Cond.Signal() 59 | b.Cond.L.Unlock() 60 | return nil 61 | } 62 | 63 | // Read reads data from the internal buffer in buf. Reads will block 64 | // if no data is available, or until the buffer is closed. 65 | func (b *buffer) Read(buf []byte) (n int, err error) { 66 | b.Cond.L.Lock() 67 | defer b.Cond.L.Unlock() 68 | 69 | for len(buf) > 0 { 70 | // if there is data in b.head, copy it 71 | if len(b.head.buf) > 0 { 72 | r := copy(buf, b.head.buf) 73 | buf, b.head.buf = buf[r:], b.head.buf[r:] 74 | n += r 75 | continue 76 | } 77 | // if there is a next buffer, make it the head 78 | if len(b.head.buf) == 0 && b.head != b.tail { 79 | b.head = b.head.next 80 | continue 81 | } 82 | 83 | // if at least one byte has been copied, return 84 | if n > 0 { 85 | break 86 | } 87 | 88 | // if nothing was read, and there is nothing outstanding 89 | // check to see if the buffer is closed. 90 | if b.closed { 91 | err = io.EOF 92 | break 93 | } 94 | // out of buffers, wait for producer 95 | b.Cond.Wait() 96 | } 97 | return 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/doc.go: -------------------------------------------------------------------------------- 1 | // objx - Go package for dealing with maps, slices, JSON and other data. 2 | // 3 | // Overview 4 | // 5 | // Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes 6 | // a powerful `Get` method (among others) that allows you to easily and quickly get 7 | // access to data within the map, without having to worry too much about type assertions, 8 | // missing data, default values etc. 9 | // 10 | // Pattern 11 | // 12 | // Objx uses a preditable pattern to make access data from within `map[string]interface{}'s 13 | // easy. 14 | // 15 | // Call one of the `objx.` functions to create your `objx.Map` to get going: 16 | // 17 | // m, err := objx.FromJSON(json) 18 | // 19 | // NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong, 20 | // the rest will be optimistic and try to figure things out without panicking. 21 | // 22 | // Use `Get` to access the value you're interested in. You can use dot and array 23 | // notation too: 24 | // 25 | // m.Get("places[0].latlng") 26 | // 27 | // Once you have saught the `Value` you're interested in, you can use the `Is*` methods 28 | // to determine its type. 29 | // 30 | // if m.Get("code").IsStr() { /* ... */ } 31 | // 32 | // Or you can just assume the type, and use one of the strong type methods to 33 | // extract the real value: 34 | // 35 | // m.Get("code").Int() 36 | // 37 | // If there's no value there (or if it's the wrong type) then a default value 38 | // will be returned, or you can be explicit about the default value. 39 | // 40 | // Get("code").Int(-1) 41 | // 42 | // If you're dealing with a slice of data as a value, Objx provides many useful 43 | // methods for iterating, manipulating and selecting that data. You can find out more 44 | // by exploring the index below. 45 | // 46 | // Reading data 47 | // 48 | // A simple example of how to use Objx: 49 | // 50 | // // use MustFromJSON to make an objx.Map from some JSON 51 | // m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) 52 | // 53 | // // get the details 54 | // name := m.Get("name").Str() 55 | // age := m.Get("age").Int() 56 | // 57 | // // get their nickname (or use their name if they 58 | // // don't have one) 59 | // nickname := m.Get("nickname").Str(name) 60 | // 61 | // Ranging 62 | // 63 | // Since `objx.Map` is a `map[string]interface{}` you can treat it as such. For 64 | // example, to `range` the data, do what you would expect: 65 | // 66 | // m := objx.MustFromJSON(json) 67 | // for key, value := range m { 68 | // 69 | // /* ... do your magic ... */ 70 | // 71 | // } 72 | package objx 73 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/term_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package term 4 | 5 | type State struct { 6 | mode uint32 7 | } 8 | 9 | type Winsize struct { 10 | Height uint16 11 | Width uint16 12 | x uint16 13 | y uint16 14 | } 15 | 16 | func GetWinsize(fd uintptr) (*Winsize, error) { 17 | ws := &Winsize{} 18 | var info *CONSOLE_SCREEN_BUFFER_INFO 19 | info, err := GetConsoleScreenBufferInfo(fd) 20 | if err != nil { 21 | return nil, err 22 | } 23 | ws.Height = uint16(info.srWindow.Right - info.srWindow.Left + 1) 24 | ws.Width = uint16(info.srWindow.Bottom - info.srWindow.Top + 1) 25 | 26 | ws.x = 0 // todo azlinux -- this is the pixel size of the Window, and not currently used by any caller 27 | ws.y = 0 28 | 29 | return ws, nil 30 | } 31 | 32 | func SetWinsize(fd uintptr, ws *Winsize) error { 33 | return nil 34 | } 35 | 36 | // IsTerminal returns true if the given file descriptor is a terminal. 37 | func IsTerminal(fd uintptr) bool { 38 | _, e := GetConsoleMode(fd) 39 | return e == nil 40 | } 41 | 42 | // Restore restores the terminal connected to the given file descriptor to a 43 | // previous state. 44 | func RestoreTerminal(fd uintptr, state *State) error { 45 | return SetConsoleMode(fd, state.mode) 46 | } 47 | 48 | func SaveState(fd uintptr) (*State, error) { 49 | mode, e := GetConsoleMode(fd) 50 | if e != nil { 51 | return nil, e 52 | } 53 | return &State{mode}, nil 54 | } 55 | 56 | // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx for these flag settings 57 | func DisableEcho(fd uintptr, state *State) error { 58 | state.mode &^= (ENABLE_ECHO_INPUT) 59 | state.mode |= (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT) 60 | return SetConsoleMode(fd, state.mode) 61 | } 62 | 63 | func SetRawTerminal(fd uintptr) (*State, error) { 64 | oldState, err := MakeRaw(fd) 65 | if err != nil { 66 | return nil, err 67 | } 68 | // TODO (azlinux): implement handling interrupt and restore state of terminal 69 | return oldState, err 70 | } 71 | 72 | // MakeRaw puts the terminal connected to the given file descriptor into raw 73 | // mode and returns the previous state of the terminal so that it can be 74 | // restored. 75 | func MakeRaw(fd uintptr) (*State, error) { 76 | var state *State 77 | state, err := SaveState(fd) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx for these flag settings 83 | state.mode &^= (ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT) 84 | err = SetConsoleMode(fd, state.mode) 85 | if err != nil { 86 | return nil, err 87 | } 88 | return state, nil 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/base.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "errors" 5 | "path/filepath" 6 | ) 7 | 8 | const ( 9 | DefaultSSHUser = "root" 10 | DefaultSSHPort = 22 11 | DefaultEngineInstallURL = "https://get.docker.com" 12 | ) 13 | 14 | // BaseDriver - Embed this struct into drivers to provide the common set 15 | // of fields and functions. 16 | type BaseDriver struct { 17 | IPAddress string 18 | MachineName string 19 | SSHUser string 20 | SSHPort int 21 | SSHKeyPath string 22 | StorePath string 23 | SwarmMaster bool 24 | SwarmHost string 25 | SwarmDiscovery string 26 | } 27 | 28 | // DriverName returns the name of the driver 29 | func (d *BaseDriver) DriverName() string { 30 | return "unknown" 31 | } 32 | 33 | // GetMachineName returns the machine name 34 | func (d *BaseDriver) GetMachineName() string { 35 | return d.MachineName 36 | } 37 | 38 | // GetIP returns the ip 39 | func (d *BaseDriver) GetIP() (string, error) { 40 | if d.IPAddress == "" { 41 | return "", errors.New("IP address is not set") 42 | } 43 | return d.IPAddress, nil 44 | } 45 | 46 | // GetSSHKeyPath returns the ssh key path 47 | func (d *BaseDriver) GetSSHKeyPath() string { 48 | if d.SSHKeyPath == "" { 49 | d.SSHKeyPath = d.ResolveStorePath("id_rsa") 50 | } 51 | return d.SSHKeyPath 52 | } 53 | 54 | // GetSSHPort returns the ssh port, 22 if not specified 55 | func (d *BaseDriver) GetSSHPort() (int, error) { 56 | if d.SSHPort == 0 { 57 | d.SSHPort = DefaultSSHPort 58 | } 59 | 60 | return d.SSHPort, nil 61 | } 62 | 63 | // GetSSHUsername returns the ssh user name, root if not specified 64 | func (d *BaseDriver) GetSSHUsername() string { 65 | if d.SSHUser == "" { 66 | d.SSHUser = DefaultSSHUser 67 | } 68 | return d.SSHUser 69 | } 70 | 71 | // PreCreateCheck is called to enforce pre-creation steps 72 | func (d *BaseDriver) PreCreateCheck() error { 73 | return nil 74 | } 75 | 76 | // ResolveStorePath returns the store path where the machine is 77 | func (d *BaseDriver) ResolveStorePath(file string) string { 78 | return filepath.Join(d.StorePath, "machines", d.MachineName, file) 79 | } 80 | 81 | // SetSwarmConfigFromFlags configures the driver for swarm 82 | func (d *BaseDriver) SetSwarmConfigFromFlags(flags DriverOptions) { 83 | d.SwarmMaster = flags.Bool("swarm-master") 84 | d.SwarmHost = flags.String("swarm-host") 85 | d.SwarmDiscovery = flags.String("swarm-discovery") 86 | } 87 | 88 | func EngineInstallURLFlagSet(flags DriverOptions) bool { 89 | engineInstallURLFlag := flags.String("engine-install-url") 90 | return engineInstallURLFlag != DefaultEngineInstallURL && engineInstallURLFlag != "" 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/conversions.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "bytes" 5 | "encoding/base64" 6 | "encoding/json" 7 | "errors" 8 | "fmt" 9 | "net/url" 10 | ) 11 | 12 | // JSON converts the contained object to a JSON string 13 | // representation 14 | func (m Map) JSON() (string, error) { 15 | 16 | result, err := json.Marshal(m) 17 | 18 | if err != nil { 19 | err = errors.New("objx: JSON encode failed with: " + err.Error()) 20 | } 21 | 22 | return string(result), err 23 | 24 | } 25 | 26 | // MustJSON converts the contained object to a JSON string 27 | // representation and panics if there is an error 28 | func (m Map) MustJSON() string { 29 | result, err := m.JSON() 30 | if err != nil { 31 | panic(err.Error()) 32 | } 33 | return result 34 | } 35 | 36 | // Base64 converts the contained object to a Base64 string 37 | // representation of the JSON string representation 38 | func (m Map) Base64() (string, error) { 39 | 40 | var buf bytes.Buffer 41 | 42 | jsonData, err := m.JSON() 43 | if err != nil { 44 | return "", err 45 | } 46 | 47 | encoder := base64.NewEncoder(base64.StdEncoding, &buf) 48 | encoder.Write([]byte(jsonData)) 49 | encoder.Close() 50 | 51 | return buf.String(), nil 52 | 53 | } 54 | 55 | // MustBase64 converts the contained object to a Base64 string 56 | // representation of the JSON string representation and panics 57 | // if there is an error 58 | func (m Map) MustBase64() string { 59 | result, err := m.Base64() 60 | if err != nil { 61 | panic(err.Error()) 62 | } 63 | return result 64 | } 65 | 66 | // SignedBase64 converts the contained object to a Base64 string 67 | // representation of the JSON string representation and signs it 68 | // using the provided key. 69 | func (m Map) SignedBase64(key string) (string, error) { 70 | 71 | base64, err := m.Base64() 72 | if err != nil { 73 | return "", err 74 | } 75 | 76 | sig := HashWithKey(base64, key) 77 | 78 | return base64 + SignatureSeparator + sig, nil 79 | 80 | } 81 | 82 | // MustSignedBase64 converts the contained object to a Base64 string 83 | // representation of the JSON string representation and signs it 84 | // using the provided key and panics if there is an error 85 | func (m Map) MustSignedBase64(key string) string { 86 | result, err := m.SignedBase64(key) 87 | if err != nil { 88 | panic(err.Error()) 89 | } 90 | return result 91 | } 92 | 93 | /* 94 | URL Query 95 | ------------------------------------------------ 96 | */ 97 | 98 | // URLValues creates a url.Values object from an Obj. This 99 | // function requires that the wrapped object be a map[string]interface{} 100 | func (m Map) URLValues() url.Values { 101 | 102 | vals := make(url.Values) 103 | 104 | for k, v := range m { 105 | //TODO: can this be done without sprintf? 106 | vals.Set(k, fmt.Sprintf("%v", v)) 107 | } 108 | 109 | return vals 110 | } 111 | 112 | // URLQuery gets an encoded URL query representing the given 113 | // Obj. This function requires that the wrapped object be a 114 | // map[string]interface{} 115 | func (m Map) URLQuery() (string, error) { 116 | return m.URLValues().Encode(), nil 117 | } 118 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/square_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func square(out, in *[5]uint64) 11 | TEXT ·square(SB),7,$96-16 12 | MOVQ out+0(FP), DI 13 | MOVQ in+8(FP), SI 14 | 15 | MOVQ SP,R11 16 | MOVQ $31,CX 17 | NOTQ CX 18 | ANDQ CX,SP 19 | ADDQ $32, SP 20 | 21 | MOVQ R11,0(SP) 22 | MOVQ R12,8(SP) 23 | MOVQ R13,16(SP) 24 | MOVQ R14,24(SP) 25 | MOVQ R15,32(SP) 26 | MOVQ BX,40(SP) 27 | MOVQ BP,48(SP) 28 | MOVQ 0(SI),AX 29 | MULQ 0(SI) 30 | MOVQ AX,CX 31 | MOVQ DX,R8 32 | MOVQ 0(SI),AX 33 | SHLQ $1,AX 34 | MULQ 8(SI) 35 | MOVQ AX,R9 36 | MOVQ DX,R10 37 | MOVQ 0(SI),AX 38 | SHLQ $1,AX 39 | MULQ 16(SI) 40 | MOVQ AX,R11 41 | MOVQ DX,R12 42 | MOVQ 0(SI),AX 43 | SHLQ $1,AX 44 | MULQ 24(SI) 45 | MOVQ AX,R13 46 | MOVQ DX,R14 47 | MOVQ 0(SI),AX 48 | SHLQ $1,AX 49 | MULQ 32(SI) 50 | MOVQ AX,R15 51 | MOVQ DX,BX 52 | MOVQ 8(SI),AX 53 | MULQ 8(SI) 54 | ADDQ AX,R11 55 | ADCQ DX,R12 56 | MOVQ 8(SI),AX 57 | SHLQ $1,AX 58 | MULQ 16(SI) 59 | ADDQ AX,R13 60 | ADCQ DX,R14 61 | MOVQ 8(SI),AX 62 | SHLQ $1,AX 63 | MULQ 24(SI) 64 | ADDQ AX,R15 65 | ADCQ DX,BX 66 | MOVQ 8(SI),DX 67 | IMUL3Q $38,DX,AX 68 | MULQ 32(SI) 69 | ADDQ AX,CX 70 | ADCQ DX,R8 71 | MOVQ 16(SI),AX 72 | MULQ 16(SI) 73 | ADDQ AX,R15 74 | ADCQ DX,BX 75 | MOVQ 16(SI),DX 76 | IMUL3Q $38,DX,AX 77 | MULQ 24(SI) 78 | ADDQ AX,CX 79 | ADCQ DX,R8 80 | MOVQ 16(SI),DX 81 | IMUL3Q $38,DX,AX 82 | MULQ 32(SI) 83 | ADDQ AX,R9 84 | ADCQ DX,R10 85 | MOVQ 24(SI),DX 86 | IMUL3Q $19,DX,AX 87 | MULQ 24(SI) 88 | ADDQ AX,R9 89 | ADCQ DX,R10 90 | MOVQ 24(SI),DX 91 | IMUL3Q $38,DX,AX 92 | MULQ 32(SI) 93 | ADDQ AX,R11 94 | ADCQ DX,R12 95 | MOVQ 32(SI),DX 96 | IMUL3Q $19,DX,AX 97 | MULQ 32(SI) 98 | ADDQ AX,R13 99 | ADCQ DX,R14 100 | MOVQ ·REDMASK51(SB),SI 101 | SHLQ $13,R8:CX 102 | ANDQ SI,CX 103 | SHLQ $13,R10:R9 104 | ANDQ SI,R9 105 | ADDQ R8,R9 106 | SHLQ $13,R12:R11 107 | ANDQ SI,R11 108 | ADDQ R10,R11 109 | SHLQ $13,R14:R13 110 | ANDQ SI,R13 111 | ADDQ R12,R13 112 | SHLQ $13,BX:R15 113 | ANDQ SI,R15 114 | ADDQ R14,R15 115 | IMUL3Q $19,BX,DX 116 | ADDQ DX,CX 117 | MOVQ CX,DX 118 | SHRQ $51,DX 119 | ADDQ R9,DX 120 | ANDQ SI,CX 121 | MOVQ DX,R8 122 | SHRQ $51,DX 123 | ADDQ R11,DX 124 | ANDQ SI,R8 125 | MOVQ DX,R9 126 | SHRQ $51,DX 127 | ADDQ R13,DX 128 | ANDQ SI,R9 129 | MOVQ DX,AX 130 | SHRQ $51,DX 131 | ADDQ R15,DX 132 | ANDQ SI,AX 133 | MOVQ DX,R10 134 | SHRQ $51,DX 135 | IMUL3Q $19,DX,DX 136 | ADDQ DX,CX 137 | ANDQ SI,R10 138 | MOVQ CX,0(DI) 139 | MOVQ R8,8(DI) 140 | MOVQ R9,16(DI) 141 | MOVQ AX,24(DI) 142 | MOVQ R10,32(DI) 143 | MOVQ 0(SP),R11 144 | MOVQ 8(SP),R12 145 | MOVQ 16(SP),R13 146 | MOVQ 24(SP),R14 147 | MOVQ 32(SP),R15 148 | MOVQ 40(SP),BX 149 | MOVQ 48(SP),BP 150 | MOVQ R11,SP 151 | MOVQ DI,AX 152 | MOVQ SI,DX 153 | RET 154 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/drivers.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/docker/machine/libmachine/log" 7 | "github.com/docker/machine/libmachine/mcnflag" 8 | "github.com/docker/machine/libmachine/state" 9 | ) 10 | 11 | // Driver defines how a host is created and controlled. Different types of 12 | // driver represent different ways hosts can be created (e.g. different 13 | // hypervisors, different cloud providers) 14 | type Driver interface { 15 | // Create a host using the driver's config 16 | Create() error 17 | 18 | // DriverName returns the name of the driver 19 | DriverName() string 20 | 21 | // GetCreateFlags returns the mcnflag.Flag slice representing the flags 22 | // that can be set, their descriptions and defaults. 23 | GetCreateFlags() []mcnflag.Flag 24 | 25 | // GetIP returns an IP or hostname that this host is available at 26 | // e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net 27 | GetIP() (string, error) 28 | 29 | // GetMachineName returns the name of the machine 30 | GetMachineName() string 31 | 32 | // GetSSHHostname returns hostname for use with ssh 33 | GetSSHHostname() (string, error) 34 | 35 | // GetSSHKeyPath returns key path for use with ssh 36 | GetSSHKeyPath() string 37 | 38 | // GetSSHPort returns port for use with ssh 39 | GetSSHPort() (int, error) 40 | 41 | // GetSSHUsername returns username for use with ssh 42 | GetSSHUsername() string 43 | 44 | // GetURL returns a Docker compatible host URL for connecting to this host 45 | // e.g. tcp://1.2.3.4:2376 46 | GetURL() (string, error) 47 | 48 | // GetState returns the state that the host is in (running, stopped, etc) 49 | GetState() (state.State, error) 50 | 51 | // Kill stops a host forcefully 52 | Kill() error 53 | 54 | // PreCreateCheck allows for pre-create operations to make sure a driver is ready for creation 55 | PreCreateCheck() error 56 | 57 | // Remove a host 58 | Remove() error 59 | 60 | // Restart a host. This may just call Stop(); Start() if the provider does not 61 | // have any special restart behaviour. 62 | Restart() error 63 | 64 | // SetConfigFromFlags configures the driver with the object that was returned 65 | // by RegisterCreateFlags 66 | SetConfigFromFlags(opts DriverOptions) error 67 | 68 | // Start a host 69 | Start() error 70 | 71 | // Stop a host gracefully 72 | Stop() error 73 | } 74 | 75 | var ErrHostIsNotRunning = errors.New("Host is not running") 76 | 77 | type DriverOptions interface { 78 | String(key string) string 79 | StringSlice(key string) []string 80 | Int(key string) int 81 | Bool(key string) bool 82 | } 83 | 84 | func MachineInState(d Driver, desiredState state.State) func() bool { 85 | return func() bool { 86 | currentState, err := d.GetState() 87 | if err != nil { 88 | log.Debugf("Error getting machine state: %s", err) 89 | } 90 | if currentState == desiredState { 91 | return true 92 | } 93 | return false 94 | } 95 | } 96 | 97 | // MustBeRunning will return an error if the machine is not in a running state. 98 | func MustBeRunning(d Driver) error { 99 | s, err := d.GetState() 100 | if err != nil { 101 | return err 102 | } 103 | 104 | if s != state.Running { 105 | return ErrHostIsNotRunning 106 | } 107 | 108 | return nil 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/mcnutils/utils.go: -------------------------------------------------------------------------------- 1 | package mcnutils 2 | 3 | import ( 4 | "crypto/rand" 5 | "encoding/hex" 6 | "fmt" 7 | "io" 8 | "os" 9 | "runtime" 10 | "strconv" 11 | "time" 12 | ) 13 | 14 | type MultiError struct { 15 | Errs []error 16 | } 17 | 18 | func (e MultiError) Error() string { 19 | aggregate := "" 20 | for _, err := range e.Errs { 21 | aggregate += err.Error() + "\n" 22 | } 23 | return aggregate 24 | } 25 | 26 | // GetHomeDir returns the home directory 27 | // TODO: Having this here just strikes me as dangerous, but some of the drivers 28 | // depend on it ;_; 29 | func GetHomeDir() string { 30 | if runtime.GOOS == "windows" { 31 | return os.Getenv("USERPROFILE") 32 | } 33 | return os.Getenv("HOME") 34 | } 35 | 36 | func GetUsername() string { 37 | u := "unknown" 38 | osUser := "" 39 | 40 | switch runtime.GOOS { 41 | case "darwin", "linux": 42 | osUser = os.Getenv("USER") 43 | case "windows": 44 | osUser = os.Getenv("USERNAME") 45 | } 46 | 47 | if osUser != "" { 48 | u = osUser 49 | } 50 | 51 | return u 52 | } 53 | 54 | func CopyFile(src, dst string) error { 55 | in, err := os.Open(src) 56 | if err != nil { 57 | return err 58 | } 59 | 60 | defer in.Close() 61 | 62 | out, err := os.Create(dst) 63 | if err != nil { 64 | return err 65 | } 66 | 67 | defer out.Close() 68 | 69 | if _, err = io.Copy(out, in); err != nil { 70 | return err 71 | } 72 | 73 | fi, err := os.Stat(src) 74 | if err != nil { 75 | return err 76 | } 77 | 78 | return os.Chmod(dst, fi.Mode()) 79 | } 80 | 81 | func WaitForSpecificOrError(f func() (bool, error), maxAttempts int, waitInterval time.Duration) error { 82 | for i := 0; i < maxAttempts; i++ { 83 | stop, err := f() 84 | if err != nil { 85 | return err 86 | } 87 | if stop { 88 | return nil 89 | } 90 | time.Sleep(waitInterval) 91 | } 92 | return fmt.Errorf("Maximum number of retries (%d) exceeded", maxAttempts) 93 | } 94 | 95 | func WaitForSpecific(f func() bool, maxAttempts int, waitInterval time.Duration) error { 96 | return WaitForSpecificOrError(func() (bool, error) { 97 | return f(), nil 98 | }, maxAttempts, waitInterval) 99 | } 100 | 101 | func WaitFor(f func() bool) error { 102 | return WaitForSpecific(f, 60, 3*time.Second) 103 | } 104 | 105 | // TruncateID returns a shorten id 106 | // Following two functions are from github.com/docker/docker/utils module. It 107 | // was way overkill to include the whole module, so we just have these bits 108 | // that we're using here. 109 | func TruncateID(id string) string { 110 | shortLen := 12 111 | if len(id) < shortLen { 112 | shortLen = len(id) 113 | } 114 | return id[:shortLen] 115 | } 116 | 117 | // GenerateRandomID returns an unique id 118 | func GenerateRandomID() string { 119 | for { 120 | id := make([]byte, 32) 121 | if _, err := io.ReadFull(rand.Reader, id); err != nil { 122 | panic(err) // This shouldn't happen 123 | } 124 | value := hex.EncodeToString(id) 125 | // if we try to parse the truncated for as an int and we don't have 126 | // an error then the value is all numeric and causes issues when 127 | // used as a hostname. ref #3869 128 | if _, err := strconv.ParseInt(TruncateID(value), 10, 64); err == nil { 129 | continue 130 | } 131 | return value 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/ssh/keys.go: -------------------------------------------------------------------------------- 1 | package ssh 2 | 3 | import ( 4 | "crypto/md5" 5 | "crypto/rand" 6 | "crypto/rsa" 7 | "crypto/x509" 8 | "encoding/base64" 9 | "encoding/pem" 10 | "errors" 11 | "fmt" 12 | "io" 13 | "os" 14 | "runtime" 15 | 16 | gossh "golang.org/x/crypto/ssh" 17 | ) 18 | 19 | var ( 20 | ErrKeyGeneration = errors.New("Unable to generate key") 21 | ErrValidation = errors.New("Unable to validate key") 22 | ErrPublicKey = errors.New("Unable to convert public key") 23 | ErrUnableToWriteFile = errors.New("Unable to write file") 24 | ) 25 | 26 | type KeyPair struct { 27 | PrivateKey []byte 28 | PublicKey []byte 29 | } 30 | 31 | // NewKeyPair generates a new SSH keypair 32 | // This will return a private & public key encoded as DER. 33 | func NewKeyPair() (keyPair *KeyPair, err error) { 34 | priv, err := rsa.GenerateKey(rand.Reader, 2048) 35 | if err != nil { 36 | return nil, ErrKeyGeneration 37 | } 38 | 39 | if err := priv.Validate(); err != nil { 40 | return nil, ErrValidation 41 | } 42 | 43 | privDer := x509.MarshalPKCS1PrivateKey(priv) 44 | 45 | pubSSH, err := gossh.NewPublicKey(&priv.PublicKey) 46 | if err != nil { 47 | return nil, ErrPublicKey 48 | } 49 | 50 | return &KeyPair{ 51 | PrivateKey: privDer, 52 | PublicKey: gossh.MarshalAuthorizedKey(pubSSH), 53 | }, nil 54 | } 55 | 56 | // WriteToFile writes keypair to files 57 | func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) error { 58 | files := []struct { 59 | File string 60 | Type string 61 | Value []byte 62 | }{ 63 | { 64 | File: privateKeyPath, 65 | Value: pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Headers: nil, Bytes: kp.PrivateKey}), 66 | }, 67 | { 68 | File: publicKeyPath, 69 | Value: kp.PublicKey, 70 | }, 71 | } 72 | 73 | for _, v := range files { 74 | f, err := os.Create(v.File) 75 | if err != nil { 76 | return ErrUnableToWriteFile 77 | } 78 | 79 | if _, err := f.Write(v.Value); err != nil { 80 | return ErrUnableToWriteFile 81 | } 82 | 83 | // windows does not support chmod 84 | switch runtime.GOOS { 85 | case "darwin", "linux": 86 | if err := f.Chmod(0600); err != nil { 87 | return err 88 | } 89 | } 90 | } 91 | 92 | return nil 93 | } 94 | 95 | // Fingerprint calculates the fingerprint of the public key 96 | func (kp *KeyPair) Fingerprint() string { 97 | b, _ := base64.StdEncoding.DecodeString(string(kp.PublicKey)) 98 | h := md5.New() 99 | 100 | io.WriteString(h, string(b)) 101 | 102 | return fmt.Sprintf("%x", h.Sum(nil)) 103 | } 104 | 105 | // GenerateSSHKey generates SSH keypair based on path of the private key 106 | // The public key would be generated to the same path with ".pub" added 107 | func GenerateSSHKey(path string) error { 108 | if _, err := os.Stat(path); err != nil { 109 | if !os.IsNotExist(err) { 110 | return fmt.Errorf("Desired directory for SSH keys does not exist: %s", err) 111 | } 112 | 113 | kp, err := NewKeyPair() 114 | if err != nil { 115 | return fmt.Errorf("Error generating key pair: %s", err) 116 | } 117 | 118 | if err := kp.WriteToFile(path, fmt.Sprintf("%s.pub", path)); err != nil { 119 | return fmt.Errorf("Error writing keys to file(s): %s", err) 120 | } 121 | } 122 | 123 | return nil 124 | } 125 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/mul_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func mul(dest, a, b *[5]uint64) 11 | TEXT ·mul(SB),0,$128-24 12 | MOVQ dest+0(FP), DI 13 | MOVQ a+8(FP), SI 14 | MOVQ b+16(FP), DX 15 | 16 | MOVQ SP,R11 17 | MOVQ $31,CX 18 | NOTQ CX 19 | ANDQ CX,SP 20 | ADDQ $32,SP 21 | 22 | MOVQ R11,0(SP) 23 | MOVQ R12,8(SP) 24 | MOVQ R13,16(SP) 25 | MOVQ R14,24(SP) 26 | MOVQ R15,32(SP) 27 | MOVQ BX,40(SP) 28 | MOVQ BP,48(SP) 29 | MOVQ DI,56(SP) 30 | MOVQ DX,CX 31 | MOVQ 24(SI),DX 32 | IMUL3Q $19,DX,AX 33 | MOVQ AX,64(SP) 34 | MULQ 16(CX) 35 | MOVQ AX,R8 36 | MOVQ DX,R9 37 | MOVQ 32(SI),DX 38 | IMUL3Q $19,DX,AX 39 | MOVQ AX,72(SP) 40 | MULQ 8(CX) 41 | ADDQ AX,R8 42 | ADCQ DX,R9 43 | MOVQ 0(SI),AX 44 | MULQ 0(CX) 45 | ADDQ AX,R8 46 | ADCQ DX,R9 47 | MOVQ 0(SI),AX 48 | MULQ 8(CX) 49 | MOVQ AX,R10 50 | MOVQ DX,R11 51 | MOVQ 0(SI),AX 52 | MULQ 16(CX) 53 | MOVQ AX,R12 54 | MOVQ DX,R13 55 | MOVQ 0(SI),AX 56 | MULQ 24(CX) 57 | MOVQ AX,R14 58 | MOVQ DX,R15 59 | MOVQ 0(SI),AX 60 | MULQ 32(CX) 61 | MOVQ AX,BX 62 | MOVQ DX,BP 63 | MOVQ 8(SI),AX 64 | MULQ 0(CX) 65 | ADDQ AX,R10 66 | ADCQ DX,R11 67 | MOVQ 8(SI),AX 68 | MULQ 8(CX) 69 | ADDQ AX,R12 70 | ADCQ DX,R13 71 | MOVQ 8(SI),AX 72 | MULQ 16(CX) 73 | ADDQ AX,R14 74 | ADCQ DX,R15 75 | MOVQ 8(SI),AX 76 | MULQ 24(CX) 77 | ADDQ AX,BX 78 | ADCQ DX,BP 79 | MOVQ 8(SI),DX 80 | IMUL3Q $19,DX,AX 81 | MULQ 32(CX) 82 | ADDQ AX,R8 83 | ADCQ DX,R9 84 | MOVQ 16(SI),AX 85 | MULQ 0(CX) 86 | ADDQ AX,R12 87 | ADCQ DX,R13 88 | MOVQ 16(SI),AX 89 | MULQ 8(CX) 90 | ADDQ AX,R14 91 | ADCQ DX,R15 92 | MOVQ 16(SI),AX 93 | MULQ 16(CX) 94 | ADDQ AX,BX 95 | ADCQ DX,BP 96 | MOVQ 16(SI),DX 97 | IMUL3Q $19,DX,AX 98 | MULQ 24(CX) 99 | ADDQ AX,R8 100 | ADCQ DX,R9 101 | MOVQ 16(SI),DX 102 | IMUL3Q $19,DX,AX 103 | MULQ 32(CX) 104 | ADDQ AX,R10 105 | ADCQ DX,R11 106 | MOVQ 24(SI),AX 107 | MULQ 0(CX) 108 | ADDQ AX,R14 109 | ADCQ DX,R15 110 | MOVQ 24(SI),AX 111 | MULQ 8(CX) 112 | ADDQ AX,BX 113 | ADCQ DX,BP 114 | MOVQ 64(SP),AX 115 | MULQ 24(CX) 116 | ADDQ AX,R10 117 | ADCQ DX,R11 118 | MOVQ 64(SP),AX 119 | MULQ 32(CX) 120 | ADDQ AX,R12 121 | ADCQ DX,R13 122 | MOVQ 32(SI),AX 123 | MULQ 0(CX) 124 | ADDQ AX,BX 125 | ADCQ DX,BP 126 | MOVQ 72(SP),AX 127 | MULQ 16(CX) 128 | ADDQ AX,R10 129 | ADCQ DX,R11 130 | MOVQ 72(SP),AX 131 | MULQ 24(CX) 132 | ADDQ AX,R12 133 | ADCQ DX,R13 134 | MOVQ 72(SP),AX 135 | MULQ 32(CX) 136 | ADDQ AX,R14 137 | ADCQ DX,R15 138 | MOVQ ·REDMASK51(SB),SI 139 | SHLQ $13,R9:R8 140 | ANDQ SI,R8 141 | SHLQ $13,R11:R10 142 | ANDQ SI,R10 143 | ADDQ R9,R10 144 | SHLQ $13,R13:R12 145 | ANDQ SI,R12 146 | ADDQ R11,R12 147 | SHLQ $13,R15:R14 148 | ANDQ SI,R14 149 | ADDQ R13,R14 150 | SHLQ $13,BP:BX 151 | ANDQ SI,BX 152 | ADDQ R15,BX 153 | IMUL3Q $19,BP,DX 154 | ADDQ DX,R8 155 | MOVQ R8,DX 156 | SHRQ $51,DX 157 | ADDQ R10,DX 158 | MOVQ DX,CX 159 | SHRQ $51,DX 160 | ANDQ SI,R8 161 | ADDQ R12,DX 162 | MOVQ DX,R9 163 | SHRQ $51,DX 164 | ANDQ SI,CX 165 | ADDQ R14,DX 166 | MOVQ DX,AX 167 | SHRQ $51,DX 168 | ANDQ SI,R9 169 | ADDQ BX,DX 170 | MOVQ DX,R10 171 | SHRQ $51,DX 172 | ANDQ SI,AX 173 | IMUL3Q $19,DX,DX 174 | ADDQ DX,R8 175 | ANDQ SI,R10 176 | MOVQ R8,0(DI) 177 | MOVQ CX,8(DI) 178 | MOVQ R9,16(DI) 179 | MOVQ AX,24(DI) 180 | MOVQ R10,32(DI) 181 | MOVQ 0(SP),R11 182 | MOVQ 8(SP),R12 183 | MOVQ 16(SP),R13 184 | MOVQ 24(SP),R14 185 | MOVQ 32(SP),R15 186 | MOVQ 40(SP),BX 187 | MOVQ 48(SP),BP 188 | MOVQ R11,SP 189 | MOVQ DI,AX 190 | MOVQ SI,DX 191 | RET 192 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/http_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "net/url" 8 | "strings" 9 | ) 10 | 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 12 | // if building a new request fails. 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int { 14 | w := httptest.NewRecorder() 15 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 16 | if err != nil { 17 | return -1 18 | } 19 | handler(w, req) 20 | return w.Code 21 | } 22 | 23 | // HTTPSuccess asserts that a specified handler returns a success status code. 24 | // 25 | // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 26 | // 27 | // Returns whether the assertion was successful (true) or not (false). 28 | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 29 | code := httpCode(handler, method, url, values) 30 | if code == -1 { 31 | return false 32 | } 33 | return code >= http.StatusOK && code <= http.StatusPartialContent 34 | } 35 | 36 | // HTTPRedirect asserts that a specified handler returns a redirect status code. 37 | // 38 | // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 39 | // 40 | // Returns whether the assertion was successful (true) or not (false). 41 | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 42 | code := httpCode(handler, method, url, values) 43 | if code == -1 { 44 | return false 45 | } 46 | return code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect 47 | } 48 | 49 | // HTTPError asserts that a specified handler returns an error status code. 50 | // 51 | // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 52 | // 53 | // Returns whether the assertion was successful (true) or not (false). 54 | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 55 | code := httpCode(handler, method, url, values) 56 | if code == -1 { 57 | return false 58 | } 59 | return code >= http.StatusBadRequest 60 | } 61 | 62 | // HTTPBody is a helper that returns HTTP body of the response. It returns 63 | // empty string if building a new request fails. 64 | func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { 65 | w := httptest.NewRecorder() 66 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 67 | if err != nil { 68 | return "" 69 | } 70 | handler(w, req) 71 | return w.Body.String() 72 | } 73 | 74 | // HTTPBodyContains asserts that a specified handler returns a 75 | // body that contains a string. 76 | // 77 | // assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 78 | // 79 | // Returns whether the assertion was successful (true) or not (false). 80 | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 81 | body := HTTPBody(handler, method, url, values) 82 | 83 | contains := strings.Contains(body, fmt.Sprint(str)) 84 | if !contains { 85 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 86 | } 87 | 88 | return contains 89 | } 90 | 91 | // HTTPBodyNotContains asserts that a specified handler returns a 92 | // body that does not contain a string. 93 | // 94 | // assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 95 | // 96 | // Returns whether the assertion was successful (true) or not (false). 97 | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 98 | body := HTTPBody(handler, method, url, values) 99 | 100 | contains := strings.Contains(body, fmt.Sprint(str)) 101 | if contains { 102 | Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body) 103 | } 104 | 105 | return !contains 106 | } 107 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/connection.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "fmt" 9 | "net" 10 | ) 11 | 12 | // OpenChannelError is returned if the other side rejects an 13 | // OpenChannel request. 14 | type OpenChannelError struct { 15 | Reason RejectionReason 16 | Message string 17 | } 18 | 19 | func (e *OpenChannelError) Error() string { 20 | return fmt.Sprintf("ssh: rejected: %s (%s)", e.Reason, e.Message) 21 | } 22 | 23 | // ConnMetadata holds metadata for the connection. 24 | type ConnMetadata interface { 25 | // User returns the user ID for this connection. 26 | // It is empty if no authentication is used. 27 | User() string 28 | 29 | // SessionID returns the sesson hash, also denoted by H. 30 | SessionID() []byte 31 | 32 | // ClientVersion returns the client's version string as hashed 33 | // into the session ID. 34 | ClientVersion() []byte 35 | 36 | // ServerVersion returns the server's version string as hashed 37 | // into the session ID. 38 | ServerVersion() []byte 39 | 40 | // RemoteAddr returns the remote address for this connection. 41 | RemoteAddr() net.Addr 42 | 43 | // LocalAddr returns the local address for this connection. 44 | LocalAddr() net.Addr 45 | } 46 | 47 | // Conn represents an SSH connection for both server and client roles. 48 | // Conn is the basis for implementing an application layer, such 49 | // as ClientConn, which implements the traditional shell access for 50 | // clients. 51 | type Conn interface { 52 | ConnMetadata 53 | 54 | // SendRequest sends a global request, and returns the 55 | // reply. If wantReply is true, it returns the response status 56 | // and payload. See also RFC4254, section 4. 57 | SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error) 58 | 59 | // OpenChannel tries to open an channel. If the request is 60 | // rejected, it returns *OpenChannelError. On success it returns 61 | // the SSH Channel and a Go channel for incoming, out-of-band 62 | // requests. The Go channel must be serviced, or the 63 | // connection will hang. 64 | OpenChannel(name string, data []byte) (Channel, <-chan *Request, error) 65 | 66 | // Close closes the underlying network connection 67 | Close() error 68 | 69 | // Wait blocks until the connection has shut down, and returns the 70 | // error causing the shutdown. 71 | Wait() error 72 | 73 | // TODO(hanwen): consider exposing: 74 | // RequestKeyChange 75 | // Disconnect 76 | } 77 | 78 | // DiscardRequests consumes and rejects all requests from the 79 | // passed-in channel. 80 | func DiscardRequests(in <-chan *Request) { 81 | for req := range in { 82 | if req.WantReply { 83 | req.Reply(false, nil) 84 | } 85 | } 86 | } 87 | 88 | // A connection represents an incoming connection. 89 | type connection struct { 90 | transport *handshakeTransport 91 | sshConn 92 | 93 | // The connection protocol. 94 | *mux 95 | } 96 | 97 | func (c *connection) Close() error { 98 | return c.sshConn.conn.Close() 99 | } 100 | 101 | // sshconn provides net.Conn metadata, but disallows direct reads and 102 | // writes. 103 | type sshConn struct { 104 | conn net.Conn 105 | 106 | user string 107 | sessionID []byte 108 | clientVersion []byte 109 | serverVersion []byte 110 | } 111 | 112 | func dup(src []byte) []byte { 113 | dst := make([]byte, len(src)) 114 | copy(dst, src) 115 | return dst 116 | } 117 | 118 | func (c *sshConn) User() string { 119 | return c.user 120 | } 121 | 122 | func (c *sshConn) RemoteAddr() net.Addr { 123 | return c.conn.RemoteAddr() 124 | } 125 | 126 | func (c *sshConn) Close() error { 127 | return c.conn.Close() 128 | } 129 | 130 | func (c *sshConn) LocalAddr() net.Addr { 131 | return c.conn.LocalAddr() 132 | } 133 | 134 | func (c *sshConn) SessionID() []byte { 135 | return dup(c.sessionID) 136 | } 137 | 138 | func (c *sshConn) ClientVersion() []byte { 139 | return dup(c.clientVersion) 140 | } 141 | 142 | func (c *sshConn) ServerVersion() []byte { 143 | return dup(c.serverVersion) 144 | } 145 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Machine GoDaddy Driver 2 | 3 | A [Docker Machine](https://docs.docker.com/machine/) driver plugin for [GoDaddy Cloud Servers](https://www.godaddy.com/pro/cloud-servers). 4 | 5 | ## Requirements 6 | 7 | * [Docker Machine](https://docs.docker.com/machine/install-machine/) 0.5.1 or a newer version 8 | 9 | ## Installation 10 | 11 | ### Releases 12 | 13 | For a simple single-line install, run the following: 14 | 15 | ```bash 16 | $ curl -L https://git.io/virTz | sudo bash 17 | ``` 18 | 19 | Not a fan of `curl | bash`? No problem. 20 | 21 | Download the latest version of `docker-machine-driver-godaddy` from [GitHub Releases](https://github.com/godaddy/docker-machine-godaddy/releases), 22 | ensure the plugin is executable, and copy to a directory included in your environment's PATH variable: 23 | 24 | ```bash 25 | $ curl -L https://github.com/godaddy/docker-machine-godaddy/releases/download/v1.0.0/docker-machine-driver-godaddy-$(uname -s) > docker-machine-driver-godaddy 26 | $ chmod +x docker-machine-driver-godaddy 27 | $ mv docker-machine-driver-godaddy /usr/local/lib/ # use sudo if necessary 28 | ``` 29 | 30 | ### From Source 31 | 32 | Ensure [Go](http://www.golang.org) and [Godep](https://github.com/tools/godep) are properly installed and your $GOPATH variable is set. 33 | 34 | ```bash 35 | $ go get -u github.com/godaddy/docker-machine-godaddy 36 | $ cd $GOPATH/src/github.com/godaddy/docker-machine-godaddy 37 | $ make build 38 | $ make install 39 | ``` 40 | 41 | ## Usage 42 | 43 | Official documentation for Docker Machine [is available here](https://docs.docker.com/machine/). 44 | 45 | To create machines on [GoDaddy Cloud Servers](https://www.godaddy.com/pro/cloud-servers) 46 | you will need an API key associated with your GoDaddy account. API keys can be obtained 47 | on the [GoDaddy Developer Portal](https://developer.godaddy.com/keys/). 48 | 49 | With an API key in hand, you can create a new server with: 50 | 51 | ```bash 52 | $ docker-machine create --driver godaddy --godaddy-api-key=${APIKEY} myhost 53 | ``` 54 | 55 | Alternatively, you can use environment variables: 56 | 57 | ```bash 58 | $ export GODADDY_API_KEY=${APIKEY} 59 | $ docker-machine create -d godaddy myhost 60 | ``` 61 | 62 | Options: 63 | 64 | - `--godaddy-api-key`: Your GoDaddy API key. 65 | - `--godaddy-base-api-url`: The GoDaddy API endpoint. 66 | - `--godaddy-boot-timeout`: Amount of time (in seconds) to wait for the initial boot. 67 | - `--godaddy-image`: The image to use for the new server. 68 | - `--godaddy-spec`: The server spec to use for the new server. 69 | - `--godaddy-ssh-key`: Private keyfile to use for SSH (absolute path). 70 | - `--godaddy-ssh-key-id`: Id of the existing GoDaddy SSH Key to associate with this new server. 71 | - `--godaddy-data-center`: The GoDaddy data center to launch the server in. 72 | - `--godaddy-zone`: The data center zone to launch the server in. 73 | - `--godaddy-ssh-user`: Name of the user to be used for SSH. 74 | 75 | 76 | 77 | Environment variables and default values: 78 | 79 | | CLI option | Environment variable | Default | 80 | | ------------------------------- | ---------------------------- | --------------------------------- | 81 | | `--godaddy-api-key` | `GODADDY_API_KEY` | - | 82 | | `--godaddy-base-api-url` | `GODADDY_API_URL` | `https://api.godaddy.com` | 83 | | `--godaddy-boot-timeout` | `GODADDY_BOOT_TIMEOUT` | `120` | 84 | | `--godaddy-image` | `GODADDY_IMAGE` | `ubuntu-1604` | 85 | | `--godaddy-spec` | `GODADDY_SPEC` | `tiny` | 86 | | `--godaddy-ssh-key` | `GODADDY_SSH_KEY` | - | 87 | | `--godaddy-ssh-key-id` | `GODADDY_SSH_KEY_ID` | - | 88 | | `--godaddy-data-center` | `GODADDY_DATA_CENTER` | `phx` | 89 | | `--godaddy-zone` | `GODADDY_ZONE` | `phx-1` | 90 | | `--godaddy-ssh-user` | `GODADDY_SSH_USER` | `machine` | 91 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/godaddy/docker-machine-godaddy", 3 | "GoVersion": "go1.6", 4 | "GodepVersion": "v74", 5 | "Packages": [ 6 | "github.com/godaddy/docker-machine-godaddy", 7 | "github.com/godaddy/docker-machine-godaddy/bin", 8 | "github.com/godaddy/docker-machine-godaddy/cloud" 9 | ], 10 | "Deps": [ 11 | { 12 | "ImportPath": "github.com/davecgh/go-spew/spew", 13 | "Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d" 14 | }, 15 | { 16 | "ImportPath": "github.com/dghubble/sling", 17 | "Comment": "v1.0-22-g9da07f0", 18 | "Rev": "9da07f0db0226d82803fc7374dba08506d29da00" 19 | }, 20 | { 21 | "ImportPath": "github.com/docker/docker/pkg/term", 22 | "Comment": "v1.5.0", 23 | "Rev": "a8a31eff10544860d2188dddabdee4d727545796" 24 | }, 25 | { 26 | "ImportPath": "github.com/docker/machine/libmachine/drivers", 27 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 28 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 29 | }, 30 | { 31 | "ImportPath": "github.com/docker/machine/libmachine/drivers/plugin", 32 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 33 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 34 | }, 35 | { 36 | "ImportPath": "github.com/docker/machine/libmachine/drivers/plugin/localbinary", 37 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 38 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 39 | }, 40 | { 41 | "ImportPath": "github.com/docker/machine/libmachine/drivers/rpc", 42 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 43 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 44 | }, 45 | { 46 | "ImportPath": "github.com/docker/machine/libmachine/engine", 47 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 48 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 49 | }, 50 | { 51 | "ImportPath": "github.com/docker/machine/libmachine/log", 52 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 53 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 54 | }, 55 | { 56 | "ImportPath": "github.com/docker/machine/libmachine/mcnflag", 57 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 58 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 59 | }, 60 | { 61 | "ImportPath": "github.com/docker/machine/libmachine/mcnutils", 62 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 63 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 64 | }, 65 | { 66 | "ImportPath": "github.com/docker/machine/libmachine/ssh", 67 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 68 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 69 | }, 70 | { 71 | "ImportPath": "github.com/docker/machine/libmachine/state", 72 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 73 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 74 | }, 75 | { 76 | "ImportPath": "github.com/docker/machine/libmachine/version", 77 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 78 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 79 | }, 80 | { 81 | "ImportPath": "github.com/docker/machine/version", 82 | "Comment": "docs-v0.8.0-2016-07-28-18-gf1789ea", 83 | "Rev": "f1789ea84ace57e98e4dc687ef6d6d318122b38d" 84 | }, 85 | { 86 | "ImportPath": "github.com/google/go-querystring/query", 87 | "Rev": "30f7a39f4a218feb5325f3aebc60c32a572a8274" 88 | }, 89 | { 90 | "ImportPath": "github.com/pmezard/go-difflib/difflib", 91 | "Rev": "792786c7400a136282c1664665ae0a8db921c6c2" 92 | }, 93 | { 94 | "ImportPath": "github.com/stretchr/objx", 95 | "Rev": "1a9d0bb9f541897e62256577b352fdbc1fb4fd94" 96 | }, 97 | { 98 | "ImportPath": "github.com/stretchr/testify/assert", 99 | "Comment": "v1.1.3-4-g1f4a164", 100 | "Rev": "1f4a1643a57e798696635ea4c126e9127adb7d3c" 101 | }, 102 | { 103 | "ImportPath": "github.com/stretchr/testify/mock", 104 | "Comment": "v1.1.3-4-g1f4a164", 105 | "Rev": "1f4a1643a57e798696635ea4c126e9127adb7d3c" 106 | }, 107 | { 108 | "ImportPath": "golang.org/x/crypto/curve25519", 109 | "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" 110 | }, 111 | { 112 | "ImportPath": "golang.org/x/crypto/ssh", 113 | "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" 114 | }, 115 | { 116 | "ImportPath": "golang.org/x/crypto/ssh/terminal", 117 | "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" 118 | } 119 | ] 120 | } 121 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal 18 | 19 | import ( 20 | "io" 21 | "syscall" 22 | "unsafe" 23 | ) 24 | 25 | // State contains the state of a terminal. 26 | type State struct { 27 | termios syscall.Termios 28 | } 29 | 30 | // IsTerminal returns true if the given file descriptor is a terminal. 31 | func IsTerminal(fd int) bool { 32 | var termios syscall.Termios 33 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 34 | return err == 0 35 | } 36 | 37 | // MakeRaw put the terminal connected to the given file descriptor into raw 38 | // mode and returns the previous state of the terminal so that it can be 39 | // restored. 40 | func MakeRaw(fd int) (*State, error) { 41 | var oldState State 42 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { 43 | return nil, err 44 | } 45 | 46 | newState := oldState.termios 47 | newState.Iflag &^= syscall.ISTRIP | syscall.INLCR | syscall.ICRNL | syscall.IGNCR | syscall.IXON | syscall.IXOFF 48 | newState.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.ISIG 49 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { 50 | return nil, err 51 | } 52 | 53 | return &oldState, nil 54 | } 55 | 56 | // GetState returns the current state of a terminal which may be useful to 57 | // restore the terminal after a signal. 58 | func GetState(fd int) (*State, error) { 59 | var oldState State 60 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { 61 | return nil, err 62 | } 63 | 64 | return &oldState, nil 65 | } 66 | 67 | // Restore restores the terminal connected to the given file descriptor to a 68 | // previous state. 69 | func Restore(fd int, state *State) error { 70 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0) 71 | return err 72 | } 73 | 74 | // GetSize returns the dimensions of the given terminal. 75 | func GetSize(fd int) (width, height int, err error) { 76 | var dimensions [4]uint16 77 | 78 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 { 79 | return -1, -1, err 80 | } 81 | return int(dimensions[1]), int(dimensions[0]), nil 82 | } 83 | 84 | // ReadPassword reads a line of input from a terminal without local echo. This 85 | // is commonly used for inputting passwords and other sensitive data. The slice 86 | // returned does not include the \n. 87 | func ReadPassword(fd int) ([]byte, error) { 88 | var oldState syscall.Termios 89 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); err != 0 { 90 | return nil, err 91 | } 92 | 93 | newState := oldState 94 | newState.Lflag &^= syscall.ECHO 95 | newState.Lflag |= syscall.ICANON | syscall.ISIG 96 | newState.Iflag |= syscall.ICRNL 97 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { 98 | return nil, err 99 | } 100 | 101 | defer func() { 102 | syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0) 103 | }() 104 | 105 | var buf [16]byte 106 | var ret []byte 107 | for { 108 | n, err := syscall.Read(fd, buf[:]) 109 | if err != nil { 110 | return nil, err 111 | } 112 | if n == 0 { 113 | if len(ret) == 0 { 114 | return nil, io.EOF 115 | } 116 | break 117 | } 118 | if buf[n-1] == '\n' { 119 | n-- 120 | } 121 | ret = append(ret, buf[:n]...) 122 | if n < len(buf) { 123 | break 124 | } 125 | } 126 | 127 | return ret, nil 128 | } 129 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/serial.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "sync" 5 | 6 | "encoding/json" 7 | 8 | "github.com/docker/machine/libmachine/mcnflag" 9 | "github.com/docker/machine/libmachine/state" 10 | ) 11 | 12 | var stdLock = &sync.Mutex{} 13 | 14 | // SerialDriver is a wrapper struct which is used to ensure that RPC calls 15 | // to a driver only occur one at a time. 16 | // Some providers, e.g. virtualbox, should not run driver operations at the 17 | // same time as other driver instances of the same type. Otherwise, we scrape 18 | // up against VirtualBox's own locking mechanisms. 19 | // 20 | // It would be preferable to simply have a lock around, say, the VBoxManage 21 | // command, but with our current one-server-process-per-machine model it is 22 | // impossible to dictate this locking on the server side. 23 | type SerialDriver struct { 24 | Driver 25 | sync.Locker 26 | } 27 | 28 | func NewSerialDriver(innerDriver Driver) Driver { 29 | return newSerialDriverWithLock(innerDriver, stdLock) 30 | } 31 | 32 | func newSerialDriverWithLock(innerDriver Driver, lock sync.Locker) Driver { 33 | return &SerialDriver{ 34 | Driver: innerDriver, 35 | Locker: lock, 36 | } 37 | } 38 | 39 | // Create a host using the driver's config 40 | func (d *SerialDriver) Create() error { 41 | d.Lock() 42 | defer d.Unlock() 43 | return d.Driver.Create() 44 | } 45 | 46 | // DriverName returns the name of the driver as it is registered 47 | func (d *SerialDriver) DriverName() string { 48 | d.Lock() 49 | defer d.Unlock() 50 | return d.Driver.DriverName() 51 | } 52 | 53 | // GetCreateFlags returns the mcnflag.Flag slice representing the flags 54 | // that can be set, their descriptions and defaults. 55 | func (d *SerialDriver) GetCreateFlags() []mcnflag.Flag { 56 | d.Lock() 57 | defer d.Unlock() 58 | return d.Driver.GetCreateFlags() 59 | } 60 | 61 | // GetIP returns an IP or hostname that this host is available at 62 | // e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net 63 | func (d *SerialDriver) GetIP() (string, error) { 64 | d.Lock() 65 | defer d.Unlock() 66 | return d.Driver.GetIP() 67 | } 68 | 69 | // GetMachineName returns the name of the machine 70 | func (d *SerialDriver) GetMachineName() string { 71 | d.Lock() 72 | defer d.Unlock() 73 | return d.Driver.GetMachineName() 74 | } 75 | 76 | // GetSSHHostname returns hostname for use with ssh 77 | func (d *SerialDriver) GetSSHHostname() (string, error) { 78 | d.Lock() 79 | defer d.Unlock() 80 | return d.Driver.GetSSHHostname() 81 | } 82 | 83 | // GetSSHKeyPath returns key path for use with ssh 84 | func (d *SerialDriver) GetSSHKeyPath() string { 85 | d.Lock() 86 | defer d.Unlock() 87 | return d.Driver.GetSSHKeyPath() 88 | } 89 | 90 | // GetSSHPort returns port for use with ssh 91 | func (d *SerialDriver) GetSSHPort() (int, error) { 92 | d.Lock() 93 | defer d.Unlock() 94 | return d.Driver.GetSSHPort() 95 | } 96 | 97 | // GetSSHUsername returns username for use with ssh 98 | func (d *SerialDriver) GetSSHUsername() string { 99 | d.Lock() 100 | defer d.Unlock() 101 | return d.Driver.GetSSHUsername() 102 | } 103 | 104 | // GetURL returns a Docker compatible host URL for connecting to this host 105 | // e.g. tcp://1.2.3.4:2376 106 | func (d *SerialDriver) GetURL() (string, error) { 107 | d.Lock() 108 | defer d.Unlock() 109 | return d.Driver.GetURL() 110 | } 111 | 112 | // GetState returns the state that the host is in (running, stopped, etc) 113 | func (d *SerialDriver) GetState() (state.State, error) { 114 | d.Lock() 115 | defer d.Unlock() 116 | return d.Driver.GetState() 117 | } 118 | 119 | // Kill stops a host forcefully 120 | func (d *SerialDriver) Kill() error { 121 | d.Lock() 122 | defer d.Unlock() 123 | return d.Driver.Kill() 124 | } 125 | 126 | // PreCreateCheck allows for pre-create operations to make sure a driver is ready for creation 127 | func (d *SerialDriver) PreCreateCheck() error { 128 | d.Lock() 129 | defer d.Unlock() 130 | return d.Driver.PreCreateCheck() 131 | } 132 | 133 | // Remove a host 134 | func (d *SerialDriver) Remove() error { 135 | d.Lock() 136 | defer d.Unlock() 137 | return d.Driver.Remove() 138 | } 139 | 140 | // Restart a host. This may just call Stop(); Start() if the provider does not 141 | // have any special restart behaviour. 142 | func (d *SerialDriver) Restart() error { 143 | d.Lock() 144 | defer d.Unlock() 145 | return d.Driver.Restart() 146 | } 147 | 148 | // SetConfigFromFlags configures the driver with the object that was returned 149 | // by RegisterCreateFlags 150 | func (d *SerialDriver) SetConfigFromFlags(opts DriverOptions) error { 151 | d.Lock() 152 | defer d.Unlock() 153 | return d.Driver.SetConfigFromFlags(opts) 154 | } 155 | 156 | // Start a host 157 | func (d *SerialDriver) Start() error { 158 | d.Lock() 159 | defer d.Unlock() 160 | return d.Driver.Start() 161 | } 162 | 163 | // Stop a host gracefully 164 | func (d *SerialDriver) Stop() error { 165 | d.Lock() 166 | defer d.Unlock() 167 | return d.Driver.Stop() 168 | } 169 | 170 | func (d *SerialDriver) MarshalJSON() ([]byte, error) { 171 | return json.Marshal(d.Driver) 172 | } 173 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/accessors.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | // arrayAccesRegexString is the regex used to extract the array number 11 | // from the access path 12 | const arrayAccesRegexString = `^(.+)\[([0-9]+)\]$` 13 | 14 | // arrayAccesRegex is the compiled arrayAccesRegexString 15 | var arrayAccesRegex = regexp.MustCompile(arrayAccesRegexString) 16 | 17 | // Get gets the value using the specified selector and 18 | // returns it inside a new Obj object. 19 | // 20 | // If it cannot find the value, Get will return a nil 21 | // value inside an instance of Obj. 22 | // 23 | // Get can only operate directly on map[string]interface{} and []interface. 24 | // 25 | // Example 26 | // 27 | // To access the title of the third chapter of the second book, do: 28 | // 29 | // o.Get("books[1].chapters[2].title") 30 | func (m Map) Get(selector string) *Value { 31 | rawObj := access(m, selector, nil, false, false) 32 | return &Value{data: rawObj} 33 | } 34 | 35 | // Set sets the value using the specified selector and 36 | // returns the object on which Set was called. 37 | // 38 | // Set can only operate directly on map[string]interface{} and []interface 39 | // 40 | // Example 41 | // 42 | // To set the title of the third chapter of the second book, do: 43 | // 44 | // o.Set("books[1].chapters[2].title","Time to Go") 45 | func (m Map) Set(selector string, value interface{}) Map { 46 | access(m, selector, value, true, false) 47 | return m 48 | } 49 | 50 | // access accesses the object using the selector and performs the 51 | // appropriate action. 52 | func access(current, selector, value interface{}, isSet, panics bool) interface{} { 53 | 54 | switch selector.(type) { 55 | case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: 56 | 57 | if array, ok := current.([]interface{}); ok { 58 | index := intFromInterface(selector) 59 | 60 | if index >= len(array) { 61 | if panics { 62 | panic(fmt.Sprintf("objx: Index %d is out of range. Slice only contains %d items.", index, len(array))) 63 | } 64 | return nil 65 | } 66 | 67 | return array[index] 68 | } 69 | 70 | return nil 71 | 72 | case string: 73 | 74 | selStr := selector.(string) 75 | selSegs := strings.SplitN(selStr, PathSeparator, 2) 76 | thisSel := selSegs[0] 77 | index := -1 78 | var err error 79 | 80 | // https://github.com/stretchr/objx/issues/12 81 | if strings.Contains(thisSel, "[") { 82 | 83 | arrayMatches := arrayAccesRegex.FindStringSubmatch(thisSel) 84 | 85 | if len(arrayMatches) > 0 { 86 | 87 | // Get the key into the map 88 | thisSel = arrayMatches[1] 89 | 90 | // Get the index into the array at the key 91 | index, err = strconv.Atoi(arrayMatches[2]) 92 | 93 | if err != nil { 94 | // This should never happen. If it does, something has gone 95 | // seriously wrong. Panic. 96 | panic("objx: Array index is not an integer. Must use array[int].") 97 | } 98 | 99 | } 100 | } 101 | 102 | if curMap, ok := current.(Map); ok { 103 | current = map[string]interface{}(curMap) 104 | } 105 | 106 | // get the object in question 107 | switch current.(type) { 108 | case map[string]interface{}: 109 | curMSI := current.(map[string]interface{}) 110 | if len(selSegs) <= 1 && isSet { 111 | curMSI[thisSel] = value 112 | return nil 113 | } else { 114 | current = curMSI[thisSel] 115 | } 116 | default: 117 | current = nil 118 | } 119 | 120 | if current == nil && panics { 121 | panic(fmt.Sprintf("objx: '%v' invalid on object.", selector)) 122 | } 123 | 124 | // do we need to access the item of an array? 125 | if index > -1 { 126 | if array, ok := current.([]interface{}); ok { 127 | if index < len(array) { 128 | current = array[index] 129 | } else { 130 | if panics { 131 | panic(fmt.Sprintf("objx: Index %d is out of range. Slice only contains %d items.", index, len(array))) 132 | } 133 | current = nil 134 | } 135 | } 136 | } 137 | 138 | if len(selSegs) > 1 { 139 | current = access(current, selSegs[1], value, isSet, panics) 140 | } 141 | 142 | } 143 | 144 | return current 145 | 146 | } 147 | 148 | // intFromInterface converts an interface object to the largest 149 | // representation of an unsigned integer using a type switch and 150 | // assertions 151 | func intFromInterface(selector interface{}) int { 152 | var value int 153 | switch selector.(type) { 154 | case int: 155 | value = selector.(int) 156 | case int8: 157 | value = int(selector.(int8)) 158 | case int16: 159 | value = int(selector.(int16)) 160 | case int32: 161 | value = int(selector.(int32)) 162 | case int64: 163 | value = int(selector.(int64)) 164 | case uint: 165 | value = int(selector.(uint)) 166 | case uint8: 167 | value = int(selector.(uint8)) 168 | case uint16: 169 | value = int(selector.(uint16)) 170 | case uint32: 171 | value = int(selector.(uint32)) 172 | case uint64: 173 | value = int(selector.(uint64)) 174 | default: 175 | panic("objx: array access argument is not an integer type (this should never happen)") 176 | } 177 | 178 | return value 179 | } 180 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal 18 | 19 | import ( 20 | "io" 21 | "syscall" 22 | "unsafe" 23 | ) 24 | 25 | const ( 26 | enableLineInput = 2 27 | enableEchoInput = 4 28 | enableProcessedInput = 1 29 | enableWindowInput = 8 30 | enableMouseInput = 16 31 | enableInsertMode = 32 32 | enableQuickEditMode = 64 33 | enableExtendedFlags = 128 34 | enableAutoPosition = 256 35 | enableProcessedOutput = 1 36 | enableWrapAtEolOutput = 2 37 | ) 38 | 39 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 40 | 41 | var ( 42 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 43 | procSetConsoleMode = kernel32.NewProc("SetConsoleMode") 44 | procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") 45 | ) 46 | 47 | type ( 48 | short int16 49 | word uint16 50 | 51 | coord struct { 52 | x short 53 | y short 54 | } 55 | smallRect struct { 56 | left short 57 | top short 58 | right short 59 | bottom short 60 | } 61 | consoleScreenBufferInfo struct { 62 | size coord 63 | cursorPosition coord 64 | attributes word 65 | window smallRect 66 | maximumWindowSize coord 67 | } 68 | ) 69 | 70 | type State struct { 71 | mode uint32 72 | } 73 | 74 | // IsTerminal returns true if the given file descriptor is a terminal. 75 | func IsTerminal(fd int) bool { 76 | var st uint32 77 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 78 | return r != 0 && e == 0 79 | } 80 | 81 | // MakeRaw put the terminal connected to the given file descriptor into raw 82 | // mode and returns the previous state of the terminal so that it can be 83 | // restored. 84 | func MakeRaw(fd int) (*State, error) { 85 | var st uint32 86 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 87 | if e != 0 { 88 | return nil, error(e) 89 | } 90 | st &^= (enableEchoInput | enableProcessedInput | enableLineInput | enableProcessedOutput) 91 | _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(st), 0) 92 | if e != 0 { 93 | return nil, error(e) 94 | } 95 | return &State{st}, nil 96 | } 97 | 98 | // GetState returns the current state of a terminal which may be useful to 99 | // restore the terminal after a signal. 100 | func GetState(fd int) (*State, error) { 101 | var st uint32 102 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 103 | if e != 0 { 104 | return nil, error(e) 105 | } 106 | return &State{st}, nil 107 | } 108 | 109 | // Restore restores the terminal connected to the given file descriptor to a 110 | // previous state. 111 | func Restore(fd int, state *State) error { 112 | _, _, err := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(state.mode), 0) 113 | return err 114 | } 115 | 116 | // GetSize returns the dimensions of the given terminal. 117 | func GetSize(fd int) (width, height int, err error) { 118 | var info consoleScreenBufferInfo 119 | _, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&info)), 0) 120 | if e != 0 { 121 | return 0, 0, error(e) 122 | } 123 | return int(info.size.x), int(info.size.y), nil 124 | } 125 | 126 | // ReadPassword reads a line of input from a terminal without local echo. This 127 | // is commonly used for inputting passwords and other sensitive data. The slice 128 | // returned does not include the \n. 129 | func ReadPassword(fd int) ([]byte, error) { 130 | var st uint32 131 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 132 | if e != 0 { 133 | return nil, error(e) 134 | } 135 | old := st 136 | 137 | st &^= (enableEchoInput) 138 | st |= (enableProcessedInput | enableLineInput | enableProcessedOutput) 139 | _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(st), 0) 140 | if e != 0 { 141 | return nil, error(e) 142 | } 143 | 144 | defer func() { 145 | syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(old), 0) 146 | }() 147 | 148 | var buf [16]byte 149 | var ret []byte 150 | for { 151 | n, err := syscall.Read(syscall.Handle(fd), buf[:]) 152 | if err != nil { 153 | return nil, err 154 | } 155 | if n == 0 { 156 | if len(ret) == 0 { 157 | return nil, io.EOF 158 | } 159 | break 160 | } 161 | if buf[n-1] == '\n' { 162 | n-- 163 | } 164 | if n > 0 && buf[n-1] == '\r' { 165 | n-- 166 | } 167 | ret = append(ret, buf[:n]...) 168 | if n < len(buf) { 169 | break 170 | } 171 | } 172 | 173 | return ret, nil 174 | } 175 | -------------------------------------------------------------------------------- /godaddy_test.go: -------------------------------------------------------------------------------- 1 | package godaddy 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/docker/machine/libmachine/drivers" 7 | "github.com/docker/machine/libmachine/state" 8 | "github.com/stretchr/testify/assert" 9 | "github.com/stretchr/testify/mock" 10 | 11 | "github.com/godaddy/docker-machine-godaddy/cloud" 12 | ) 13 | 14 | type clientMock struct { 15 | mock.Mock 16 | } 17 | 18 | func (m clientMock) SSHKeys() *cloud.SshKeysApi { 19 | return nil 20 | } 21 | 22 | type mockServersAPI struct { 23 | *cloud.ServersApi 24 | mock.Mock 25 | } 26 | 27 | func (m *clientMock) Servers() cloud.ServersClient { 28 | args := m.Called() 29 | return args.Get(0).(cloud.ServersClient) 30 | } 31 | 32 | func (m *mockServersAPI) AddServer(server cloud.ServerCreate) (cloud.Server, error) { 33 | args := m.Called(server) 34 | return cloud.Server{ 35 | ServerId: args.String(0), 36 | Status: "NEW", 37 | }, nil 38 | } 39 | 40 | func (m *mockServersAPI) StartServer(serverID string) (cloud.ServerAction, error) { 41 | args := m.Called(serverID) 42 | return args.Get(0).(cloud.ServerAction), args.Error(1) 43 | } 44 | 45 | func (m *mockServersAPI) StopServer(serverID string) (cloud.ServerAction, error) { 46 | args := m.Called(serverID) 47 | return args.Get(0).(cloud.ServerAction), args.Error(1) 48 | } 49 | 50 | func (m *mockServersAPI) GetServerById(serverID string) (cloud.Server, error) { 51 | args := m.Called(serverID) 52 | return cloud.Server{ 53 | ServerId: serverID, 54 | PublicIp: "0.0.0.0", 55 | Status: args.String(0), 56 | }, nil 57 | } 58 | 59 | func (m *mockServersAPI) DestroyServer(serverID string) (cloud.ServerAction, error) { 60 | args := m.Called(serverID) 61 | return args.Get(0).(cloud.ServerAction), args.Error(1) 62 | } 63 | 64 | func newTestDriver() (*Driver, *clientMock) { 65 | driver := NewDriver("hostName", "someStorePath") 66 | driver.ServerID = "0h18t27z" 67 | driver.SSHKey = "~/some/key" 68 | client := new(clientMock) 69 | driver.client = func() cloud.ClientWrapper { 70 | return client 71 | } 72 | driver.createSSHKey = func() error { 73 | driver.SSHKey = driver.GetSSHKeyPath() 74 | return nil 75 | } 76 | return driver, client 77 | } 78 | 79 | func TestSetConfigFromFlags(t *testing.T) { 80 | driver := NewDriver("default", "path") 81 | 82 | checkFlags := &drivers.CheckDriverOptions{ 83 | FlagsValues: map[string]interface{}{ 84 | "godaddy-api-key": "my-api-key", 85 | "godaddy-ssh-key-id": "ssh-key", 86 | }, 87 | CreateFlags: driver.GetCreateFlags(), 88 | } 89 | 90 | err := driver.SetConfigFromFlags(checkFlags) 91 | 92 | assert.NoError(t, err) 93 | assert.Empty(t, checkFlags.InvalidFlags) 94 | } 95 | 96 | func TestCreate(t *testing.T) { 97 | driver, client := newTestDriver() 98 | servers := new(mockServersAPI) 99 | newid := "newid123" 100 | client.On("Servers").Return(servers) 101 | servers.On("AddServer", mock.AnythingOfType("cloud.ServerCreate")).Return(newid) 102 | servers.On("GetServerById", newid).Return("RUNNING") 103 | 104 | err := driver.Create() 105 | assert.NoError(t, err) 106 | } 107 | 108 | func TestStart(t *testing.T) { 109 | driver, client := newTestDriver() 110 | servers := new(mockServersAPI) 111 | client.On("Servers").Return(servers) 112 | servers.On("StartServer", driver.ServerID).Return(cloud.ServerAction{}, nil) 113 | servers.On("GetServerById", driver.ServerID).Return("RUNNING") 114 | 115 | err := driver.Start() 116 | servers.AssertCalled(t, "StartServer", driver.ServerID) 117 | assert.NoError(t, err) 118 | } 119 | 120 | func TestKill(t *testing.T) { 121 | driver, client := newTestDriver() 122 | servers := new(mockServersAPI) 123 | client.On("Servers").Return(servers) 124 | servers.On("StopServer", driver.ServerID).Return(cloud.ServerAction{}, nil) 125 | servers.On("GetServerById", driver.ServerID).Return("STOPPED") 126 | 127 | err := driver.Kill() 128 | servers.AssertCalled(t, "StopServer", driver.ServerID) 129 | assert.NoError(t, err) 130 | } 131 | 132 | func TestGetURL(t *testing.T) { 133 | driver, client := newTestDriver() 134 | servers := new(mockServersAPI) 135 | client.On("Servers").Return(servers) 136 | servers.On("GetServerById", driver.ServerID).Return("RUNNING") 137 | 138 | driver.IPAddress = "10.0.0.10" 139 | url, err := driver.GetURL() 140 | assert.NotEmpty(t, url) 141 | assert.NoError(t, err) 142 | } 143 | 144 | func TestGetState(t *testing.T) { 145 | driver, client := newTestDriver() 146 | servers := new(mockServersAPI) 147 | client.On("Servers").Return(servers) 148 | states := map[state.State][]string{ 149 | state.Starting: { 150 | "NEW", 151 | "BUILDING", 152 | "CONFIGURING_NETWORK", 153 | "VERIFYING", 154 | "STARTING", 155 | }, 156 | state.Running: {"RUNNING"}, 157 | state.None: {"DESTROYED"}, 158 | state.Stopping: {"STOPPING", "DESTROYING"}, 159 | state.Stopped: {"STOPPED"}, 160 | state.Error: {"ERROR"}, 161 | } 162 | for s, statuses := range states { 163 | for _, status := range statuses { 164 | servers.On("GetServerById", driver.ServerID).Return(status).Once() 165 | state, err := driver.GetState() 166 | assert.Equal(t, s, state) 167 | assert.NoError(t, err) 168 | } 169 | } 170 | } 171 | 172 | func TestRemove(t *testing.T) { 173 | driver, client := newTestDriver() 174 | servers := new(mockServersAPI) 175 | client.On("Servers").Return(servers) 176 | servers.On("DestroyServer", driver.ServerID).Return(cloud.ServerAction{}, nil) 177 | 178 | err := driver.Remove() 179 | servers.AssertCalled(t, "DestroyServer", driver.ServerID) 180 | assert.NoError(t, err) 181 | } 182 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypass.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is not running on Google App Engine and "-tags disableunsafe" 17 | // is not added to the go build command line. 18 | // +build !appengine,!disableunsafe 19 | 20 | package spew 21 | 22 | import ( 23 | "reflect" 24 | "unsafe" 25 | ) 26 | 27 | const ( 28 | // UnsafeDisabled is a build-time constant which specifies whether or 29 | // not access to the unsafe package is available. 30 | UnsafeDisabled = false 31 | 32 | // ptrSize is the size of a pointer on the current arch. 33 | ptrSize = unsafe.Sizeof((*byte)(nil)) 34 | ) 35 | 36 | var ( 37 | // offsetPtr, offsetScalar, and offsetFlag are the offsets for the 38 | // internal reflect.Value fields. These values are valid before golang 39 | // commit ecccf07e7f9d which changed the format. The are also valid 40 | // after commit 82f48826c6c7 which changed the format again to mirror 41 | // the original format. Code in the init function updates these offsets 42 | // as necessary. 43 | offsetPtr = uintptr(ptrSize) 44 | offsetScalar = uintptr(0) 45 | offsetFlag = uintptr(ptrSize * 2) 46 | 47 | // flagKindWidth and flagKindShift indicate various bits that the 48 | // reflect package uses internally to track kind information. 49 | // 50 | // flagRO indicates whether or not the value field of a reflect.Value is 51 | // read-only. 52 | // 53 | // flagIndir indicates whether the value field of a reflect.Value is 54 | // the actual data or a pointer to the data. 55 | // 56 | // These values are valid before golang commit 90a7c3c86944 which 57 | // changed their positions. Code in the init function updates these 58 | // flags as necessary. 59 | flagKindWidth = uintptr(5) 60 | flagKindShift = uintptr(flagKindWidth - 1) 61 | flagRO = uintptr(1 << 0) 62 | flagIndir = uintptr(1 << 1) 63 | ) 64 | 65 | func init() { 66 | // Older versions of reflect.Value stored small integers directly in the 67 | // ptr field (which is named val in the older versions). Versions 68 | // between commits ecccf07e7f9d and 82f48826c6c7 added a new field named 69 | // scalar for this purpose which unfortunately came before the flag 70 | // field, so the offset of the flag field is different for those 71 | // versions. 72 | // 73 | // This code constructs a new reflect.Value from a known small integer 74 | // and checks if the size of the reflect.Value struct indicates it has 75 | // the scalar field. When it does, the offsets are updated accordingly. 76 | vv := reflect.ValueOf(0xf00) 77 | if unsafe.Sizeof(vv) == (ptrSize * 4) { 78 | offsetScalar = ptrSize * 2 79 | offsetFlag = ptrSize * 3 80 | } 81 | 82 | // Commit 90a7c3c86944 changed the flag positions such that the low 83 | // order bits are the kind. This code extracts the kind from the flags 84 | // field and ensures it's the correct type. When it's not, the flag 85 | // order has been changed to the newer format, so the flags are updated 86 | // accordingly. 87 | upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag) 88 | upfv := *(*uintptr)(upf) 89 | flagKindMask := uintptr((1<>flagKindShift != uintptr(reflect.Int) { 91 | flagKindShift = 0 92 | flagRO = 1 << 5 93 | flagIndir = 1 << 6 94 | 95 | // Commit adf9b30e5594 modified the flags to separate the 96 | // flagRO flag into two bits which specifies whether or not the 97 | // field is embedded. This causes flagIndir to move over a bit 98 | // and means that flagRO is the combination of either of the 99 | // original flagRO bit and the new bit. 100 | // 101 | // This code detects the change by extracting what used to be 102 | // the indirect bit to ensure it's set. When it's not, the flag 103 | // order has been changed to the newer format, so the flags are 104 | // updated accordingly. 105 | if upfv&flagIndir == 0 { 106 | flagRO = 3 << 5 107 | flagIndir = 1 << 7 108 | } 109 | } 110 | } 111 | 112 | // unsafeReflectValue converts the passed reflect.Value into a one that bypasses 113 | // the typical safety restrictions preventing access to unaddressable and 114 | // unexported data. It works by digging the raw pointer to the underlying 115 | // value out of the protected value and generating a new unprotected (unsafe) 116 | // reflect.Value to it. 117 | // 118 | // This allows us to check for implementations of the Stringer and error 119 | // interfaces to be used for pretty printing ordinarily unaddressable and 120 | // inaccessible values such as unexported struct fields. 121 | func unsafeReflectValue(v reflect.Value) (rv reflect.Value) { 122 | indirects := 1 123 | vt := v.Type() 124 | upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr) 125 | rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag)) 126 | if rvf&flagIndir != 0 { 127 | vt = reflect.PtrTo(v.Type()) 128 | indirects++ 129 | } else if offsetScalar != 0 { 130 | // The value is in the scalar field when it's not one of the 131 | // reference types. 132 | switch vt.Kind() { 133 | case reflect.Uintptr: 134 | case reflect.Chan: 135 | case reflect.Func: 136 | case reflect.Map: 137 | case reflect.Ptr: 138 | case reflect.UnsafePointer: 139 | default: 140 | upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + 141 | offsetScalar) 142 | } 143 | } 144 | 145 | pv := reflect.NewAt(vt, upv) 146 | rv = pv 147 | for i := 0; i < indirects; i++ { 148 | rv = rv.Elem() 149 | } 150 | return rv 151 | } 152 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,!gccgo,!appengine 6 | 7 | package curve25519 8 | 9 | // These functions are implemented in the .s files. The names of the functions 10 | // in the rest of the file are also taken from the SUPERCOP sources to help 11 | // people following along. 12 | 13 | //go:noescape 14 | 15 | func cswap(inout *[5]uint64, v uint64) 16 | 17 | //go:noescape 18 | 19 | func ladderstep(inout *[5][5]uint64) 20 | 21 | //go:noescape 22 | 23 | func freeze(inout *[5]uint64) 24 | 25 | //go:noescape 26 | 27 | func mul(dest, a, b *[5]uint64) 28 | 29 | //go:noescape 30 | 31 | func square(out, in *[5]uint64) 32 | 33 | // mladder uses a Montgomery ladder to calculate (xr/zr) *= s. 34 | func mladder(xr, zr *[5]uint64, s *[32]byte) { 35 | var work [5][5]uint64 36 | 37 | work[0] = *xr 38 | setint(&work[1], 1) 39 | setint(&work[2], 0) 40 | work[3] = *xr 41 | setint(&work[4], 1) 42 | 43 | j := uint(6) 44 | var prevbit byte 45 | 46 | for i := 31; i >= 0; i-- { 47 | for j < 8 { 48 | bit := ((*s)[i] >> j) & 1 49 | swap := bit ^ prevbit 50 | prevbit = bit 51 | cswap(&work[1], uint64(swap)) 52 | ladderstep(&work) 53 | j-- 54 | } 55 | j = 7 56 | } 57 | 58 | *xr = work[1] 59 | *zr = work[2] 60 | } 61 | 62 | func scalarMult(out, in, base *[32]byte) { 63 | var e [32]byte 64 | copy(e[:], (*in)[:]) 65 | e[0] &= 248 66 | e[31] &= 127 67 | e[31] |= 64 68 | 69 | var t, z [5]uint64 70 | unpack(&t, base) 71 | mladder(&t, &z, &e) 72 | invert(&z, &z) 73 | mul(&t, &t, &z) 74 | pack(out, &t) 75 | } 76 | 77 | func setint(r *[5]uint64, v uint64) { 78 | r[0] = v 79 | r[1] = 0 80 | r[2] = 0 81 | r[3] = 0 82 | r[4] = 0 83 | } 84 | 85 | // unpack sets r = x where r consists of 5, 51-bit limbs in little-endian 86 | // order. 87 | func unpack(r *[5]uint64, x *[32]byte) { 88 | r[0] = uint64(x[0]) | 89 | uint64(x[1])<<8 | 90 | uint64(x[2])<<16 | 91 | uint64(x[3])<<24 | 92 | uint64(x[4])<<32 | 93 | uint64(x[5])<<40 | 94 | uint64(x[6]&7)<<48 95 | 96 | r[1] = uint64(x[6])>>3 | 97 | uint64(x[7])<<5 | 98 | uint64(x[8])<<13 | 99 | uint64(x[9])<<21 | 100 | uint64(x[10])<<29 | 101 | uint64(x[11])<<37 | 102 | uint64(x[12]&63)<<45 103 | 104 | r[2] = uint64(x[12])>>6 | 105 | uint64(x[13])<<2 | 106 | uint64(x[14])<<10 | 107 | uint64(x[15])<<18 | 108 | uint64(x[16])<<26 | 109 | uint64(x[17])<<34 | 110 | uint64(x[18])<<42 | 111 | uint64(x[19]&1)<<50 112 | 113 | r[3] = uint64(x[19])>>1 | 114 | uint64(x[20])<<7 | 115 | uint64(x[21])<<15 | 116 | uint64(x[22])<<23 | 117 | uint64(x[23])<<31 | 118 | uint64(x[24])<<39 | 119 | uint64(x[25]&15)<<47 120 | 121 | r[4] = uint64(x[25])>>4 | 122 | uint64(x[26])<<4 | 123 | uint64(x[27])<<12 | 124 | uint64(x[28])<<20 | 125 | uint64(x[29])<<28 | 126 | uint64(x[30])<<36 | 127 | uint64(x[31]&127)<<44 128 | } 129 | 130 | // pack sets out = x where out is the usual, little-endian form of the 5, 131 | // 51-bit limbs in x. 132 | func pack(out *[32]byte, x *[5]uint64) { 133 | t := *x 134 | freeze(&t) 135 | 136 | out[0] = byte(t[0]) 137 | out[1] = byte(t[0] >> 8) 138 | out[2] = byte(t[0] >> 16) 139 | out[3] = byte(t[0] >> 24) 140 | out[4] = byte(t[0] >> 32) 141 | out[5] = byte(t[0] >> 40) 142 | out[6] = byte(t[0] >> 48) 143 | 144 | out[6] ^= byte(t[1]<<3) & 0xf8 145 | out[7] = byte(t[1] >> 5) 146 | out[8] = byte(t[1] >> 13) 147 | out[9] = byte(t[1] >> 21) 148 | out[10] = byte(t[1] >> 29) 149 | out[11] = byte(t[1] >> 37) 150 | out[12] = byte(t[1] >> 45) 151 | 152 | out[12] ^= byte(t[2]<<6) & 0xc0 153 | out[13] = byte(t[2] >> 2) 154 | out[14] = byte(t[2] >> 10) 155 | out[15] = byte(t[2] >> 18) 156 | out[16] = byte(t[2] >> 26) 157 | out[17] = byte(t[2] >> 34) 158 | out[18] = byte(t[2] >> 42) 159 | out[19] = byte(t[2] >> 50) 160 | 161 | out[19] ^= byte(t[3]<<1) & 0xfe 162 | out[20] = byte(t[3] >> 7) 163 | out[21] = byte(t[3] >> 15) 164 | out[22] = byte(t[3] >> 23) 165 | out[23] = byte(t[3] >> 31) 166 | out[24] = byte(t[3] >> 39) 167 | out[25] = byte(t[3] >> 47) 168 | 169 | out[25] ^= byte(t[4]<<4) & 0xf0 170 | out[26] = byte(t[4] >> 4) 171 | out[27] = byte(t[4] >> 12) 172 | out[28] = byte(t[4] >> 20) 173 | out[29] = byte(t[4] >> 28) 174 | out[30] = byte(t[4] >> 36) 175 | out[31] = byte(t[4] >> 44) 176 | } 177 | 178 | // invert calculates r = x^-1 mod p using Fermat's little theorem. 179 | func invert(r *[5]uint64, x *[5]uint64) { 180 | var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t [5]uint64 181 | 182 | square(&z2, x) /* 2 */ 183 | square(&t, &z2) /* 4 */ 184 | square(&t, &t) /* 8 */ 185 | mul(&z9, &t, x) /* 9 */ 186 | mul(&z11, &z9, &z2) /* 11 */ 187 | square(&t, &z11) /* 22 */ 188 | mul(&z2_5_0, &t, &z9) /* 2^5 - 2^0 = 31 */ 189 | 190 | square(&t, &z2_5_0) /* 2^6 - 2^1 */ 191 | for i := 1; i < 5; i++ { /* 2^20 - 2^10 */ 192 | square(&t, &t) 193 | } 194 | mul(&z2_10_0, &t, &z2_5_0) /* 2^10 - 2^0 */ 195 | 196 | square(&t, &z2_10_0) /* 2^11 - 2^1 */ 197 | for i := 1; i < 10; i++ { /* 2^20 - 2^10 */ 198 | square(&t, &t) 199 | } 200 | mul(&z2_20_0, &t, &z2_10_0) /* 2^20 - 2^0 */ 201 | 202 | square(&t, &z2_20_0) /* 2^21 - 2^1 */ 203 | for i := 1; i < 20; i++ { /* 2^40 - 2^20 */ 204 | square(&t, &t) 205 | } 206 | mul(&t, &t, &z2_20_0) /* 2^40 - 2^0 */ 207 | 208 | square(&t, &t) /* 2^41 - 2^1 */ 209 | for i := 1; i < 10; i++ { /* 2^50 - 2^10 */ 210 | square(&t, &t) 211 | } 212 | mul(&z2_50_0, &t, &z2_10_0) /* 2^50 - 2^0 */ 213 | 214 | square(&t, &z2_50_0) /* 2^51 - 2^1 */ 215 | for i := 1; i < 50; i++ { /* 2^100 - 2^50 */ 216 | square(&t, &t) 217 | } 218 | mul(&z2_100_0, &t, &z2_50_0) /* 2^100 - 2^0 */ 219 | 220 | square(&t, &z2_100_0) /* 2^101 - 2^1 */ 221 | for i := 1; i < 100; i++ { /* 2^200 - 2^100 */ 222 | square(&t, &t) 223 | } 224 | mul(&t, &t, &z2_100_0) /* 2^200 - 2^0 */ 225 | 226 | square(&t, &t) /* 2^201 - 2^1 */ 227 | for i := 1; i < 50; i++ { /* 2^250 - 2^50 */ 228 | square(&t, &t) 229 | } 230 | mul(&t, &t, &z2_50_0) /* 2^250 - 2^0 */ 231 | 232 | square(&t, &t) /* 2^251 - 2^1 */ 233 | square(&t, &t) /* 2^252 - 2^2 */ 234 | square(&t, &t) /* 2^253 - 2^3 */ 235 | 236 | square(&t, &t) /* 2^254 - 2^4 */ 237 | 238 | square(&t, &t) /* 2^255 - 2^5 */ 239 | mul(r, &t, &z11) /* 2^255 - 21 */ 240 | } 241 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/rpc/server_driver.go: -------------------------------------------------------------------------------- 1 | package rpcdriver 2 | 3 | import ( 4 | "encoding/gob" 5 | "encoding/json" 6 | "fmt" 7 | "runtime/debug" 8 | 9 | "github.com/docker/machine/libmachine/drivers" 10 | "github.com/docker/machine/libmachine/log" 11 | "github.com/docker/machine/libmachine/mcnflag" 12 | "github.com/docker/machine/libmachine/state" 13 | "github.com/docker/machine/libmachine/version" 14 | ) 15 | 16 | type Stacker interface { 17 | Stack() []byte 18 | } 19 | 20 | type StandardStack struct{} 21 | 22 | func (ss *StandardStack) Stack() []byte { 23 | return debug.Stack() 24 | } 25 | 26 | var ( 27 | stdStacker Stacker = &StandardStack{} 28 | ) 29 | 30 | func init() { 31 | gob.Register(new(RPCFlags)) 32 | gob.Register(new(mcnflag.IntFlag)) 33 | gob.Register(new(mcnflag.StringFlag)) 34 | gob.Register(new(mcnflag.StringSliceFlag)) 35 | gob.Register(new(mcnflag.BoolFlag)) 36 | } 37 | 38 | type RPCFlags struct { 39 | Values map[string]interface{} 40 | } 41 | 42 | func (r RPCFlags) Get(key string) interface{} { 43 | val, ok := r.Values[key] 44 | if !ok { 45 | log.Warnf("Trying to access option %s which does not exist", key) 46 | log.Warn("THIS ***WILL*** CAUSE UNEXPECTED BEHAVIOR") 47 | } 48 | return val 49 | } 50 | 51 | func (r RPCFlags) String(key string) string { 52 | val, ok := r.Get(key).(string) 53 | if !ok { 54 | log.Warnf("Type assertion did not go smoothly to string for key %s", key) 55 | } 56 | return val 57 | } 58 | 59 | func (r RPCFlags) StringSlice(key string) []string { 60 | val, ok := r.Get(key).([]string) 61 | if !ok { 62 | log.Warnf("Type assertion did not go smoothly to string slice for key %s", key) 63 | } 64 | return val 65 | } 66 | 67 | func (r RPCFlags) Int(key string) int { 68 | val, ok := r.Get(key).(int) 69 | if !ok { 70 | log.Warnf("Type assertion did not go smoothly to int for key %s", key) 71 | } 72 | return val 73 | } 74 | 75 | func (r RPCFlags) Bool(key string) bool { 76 | val, ok := r.Get(key).(bool) 77 | if !ok { 78 | log.Warnf("Type assertion did not go smoothly to bool for key %s", key) 79 | } 80 | return val 81 | } 82 | 83 | type RPCServerDriver struct { 84 | ActualDriver drivers.Driver 85 | CloseCh chan bool 86 | HeartbeatCh chan bool 87 | } 88 | 89 | func NewRPCServerDriver(d drivers.Driver) *RPCServerDriver { 90 | return &RPCServerDriver{ 91 | ActualDriver: d, 92 | CloseCh: make(chan bool), 93 | HeartbeatCh: make(chan bool), 94 | } 95 | } 96 | 97 | func (r *RPCServerDriver) Close(_, _ *struct{}) error { 98 | r.CloseCh <- true 99 | return nil 100 | } 101 | 102 | func (r *RPCServerDriver) GetVersion(_ *struct{}, reply *int) error { 103 | *reply = version.APIVersion 104 | return nil 105 | } 106 | 107 | func (r *RPCServerDriver) GetConfigRaw(_ *struct{}, reply *[]byte) error { 108 | driverData, err := json.Marshal(r.ActualDriver) 109 | if err != nil { 110 | return err 111 | } 112 | 113 | *reply = driverData 114 | 115 | return nil 116 | } 117 | 118 | func (r *RPCServerDriver) GetCreateFlags(_ *struct{}, reply *[]mcnflag.Flag) error { 119 | *reply = r.ActualDriver.GetCreateFlags() 120 | return nil 121 | } 122 | 123 | func (r *RPCServerDriver) SetConfigRaw(data []byte, _ *struct{}) error { 124 | return json.Unmarshal(data, &r.ActualDriver) 125 | } 126 | 127 | func trapPanic(err *error) { 128 | if r := recover(); r != nil { 129 | *err = fmt.Errorf("Panic in the driver: %s\n%s", r.(error), stdStacker.Stack()) 130 | } 131 | } 132 | 133 | func (r *RPCServerDriver) Create(_, _ *struct{}) (err error) { 134 | // In an ideal world, plugins wouldn't ever panic. However, panics 135 | // have been known to happen and cause issues. Therefore, we recover 136 | // and do not crash the RPC server completely in the case of a panic 137 | // during create. 138 | defer trapPanic(&err) 139 | 140 | err = r.ActualDriver.Create() 141 | 142 | return err 143 | } 144 | 145 | func (r *RPCServerDriver) DriverName(_ *struct{}, reply *string) error { 146 | *reply = r.ActualDriver.DriverName() 147 | return nil 148 | } 149 | 150 | func (r *RPCServerDriver) GetIP(_ *struct{}, reply *string) error { 151 | ip, err := r.ActualDriver.GetIP() 152 | *reply = ip 153 | return err 154 | } 155 | 156 | func (r *RPCServerDriver) GetMachineName(_ *struct{}, reply *string) error { 157 | *reply = r.ActualDriver.GetMachineName() 158 | return nil 159 | } 160 | 161 | func (r *RPCServerDriver) GetSSHHostname(_ *struct{}, reply *string) error { 162 | hostname, err := r.ActualDriver.GetSSHHostname() 163 | *reply = hostname 164 | return err 165 | } 166 | 167 | func (r *RPCServerDriver) GetSSHKeyPath(_ *struct{}, reply *string) error { 168 | *reply = r.ActualDriver.GetSSHKeyPath() 169 | return nil 170 | } 171 | 172 | // GetSSHPort returns port for use with ssh 173 | func (r *RPCServerDriver) GetSSHPort(_ *struct{}, reply *int) error { 174 | port, err := r.ActualDriver.GetSSHPort() 175 | *reply = port 176 | return err 177 | } 178 | 179 | func (r *RPCServerDriver) GetSSHUsername(_ *struct{}, reply *string) error { 180 | *reply = r.ActualDriver.GetSSHUsername() 181 | return nil 182 | } 183 | 184 | func (r *RPCServerDriver) GetURL(_ *struct{}, reply *string) error { 185 | info, err := r.ActualDriver.GetURL() 186 | *reply = info 187 | return err 188 | } 189 | 190 | func (r *RPCServerDriver) GetState(_ *struct{}, reply *state.State) error { 191 | s, err := r.ActualDriver.GetState() 192 | *reply = s 193 | return err 194 | } 195 | 196 | func (r *RPCServerDriver) Kill(_ *struct{}, _ *struct{}) error { 197 | return r.ActualDriver.Kill() 198 | } 199 | 200 | func (r *RPCServerDriver) PreCreateCheck(_ *struct{}, _ *struct{}) error { 201 | return r.ActualDriver.PreCreateCheck() 202 | } 203 | 204 | func (r *RPCServerDriver) Remove(_ *struct{}, _ *struct{}) error { 205 | return r.ActualDriver.Remove() 206 | } 207 | 208 | func (r *RPCServerDriver) Restart(_ *struct{}, _ *struct{}) error { 209 | return r.ActualDriver.Restart() 210 | } 211 | 212 | func (r *RPCServerDriver) SetConfigFromFlags(flags *drivers.DriverOptions, _ *struct{}) error { 213 | return r.ActualDriver.SetConfigFromFlags(*flags) 214 | } 215 | 216 | func (r *RPCServerDriver) Start(_ *struct{}, _ *struct{}) error { 217 | return r.ActualDriver.Start() 218 | } 219 | 220 | func (r *RPCServerDriver) Stop(_ *struct{}, _ *struct{}) error { 221 | return r.ActualDriver.Stop() 222 | } 223 | 224 | func (r *RPCServerDriver) Heartbeat(_ *struct{}, _ *struct{}) error { 225 | r.HeartbeatCh <- true 226 | return nil 227 | } 228 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/map.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "errors" 7 | "io/ioutil" 8 | "net/url" 9 | "strings" 10 | ) 11 | 12 | // MSIConvertable is an interface that defines methods for converting your 13 | // custom types to a map[string]interface{} representation. 14 | type MSIConvertable interface { 15 | // MSI gets a map[string]interface{} (msi) representing the 16 | // object. 17 | MSI() map[string]interface{} 18 | } 19 | 20 | // Map provides extended functionality for working with 21 | // untyped data, in particular map[string]interface (msi). 22 | type Map map[string]interface{} 23 | 24 | // Value returns the internal value instance 25 | func (m Map) Value() *Value { 26 | return &Value{data: m} 27 | } 28 | 29 | // Nil represents a nil Map. 30 | var Nil Map = New(nil) 31 | 32 | // New creates a new Map containing the map[string]interface{} in the data argument. 33 | // If the data argument is not a map[string]interface, New attempts to call the 34 | // MSI() method on the MSIConvertable interface to create one. 35 | func New(data interface{}) Map { 36 | if _, ok := data.(map[string]interface{}); !ok { 37 | if converter, ok := data.(MSIConvertable); ok { 38 | data = converter.MSI() 39 | } else { 40 | return nil 41 | } 42 | } 43 | return Map(data.(map[string]interface{})) 44 | } 45 | 46 | // MSI creates a map[string]interface{} and puts it inside a new Map. 47 | // 48 | // The arguments follow a key, value pattern. 49 | // 50 | // Panics 51 | // 52 | // Panics if any key arugment is non-string or if there are an odd number of arguments. 53 | // 54 | // Example 55 | // 56 | // To easily create Maps: 57 | // 58 | // m := objx.MSI("name", "Mat", "age", 29, "subobj", objx.MSI("active", true)) 59 | // 60 | // // creates an Map equivalent to 61 | // m := objx.New(map[string]interface{}{"name": "Mat", "age": 29, "subobj": map[string]interface{}{"active": true}}) 62 | func MSI(keyAndValuePairs ...interface{}) Map { 63 | 64 | newMap := make(map[string]interface{}) 65 | keyAndValuePairsLen := len(keyAndValuePairs) 66 | 67 | if keyAndValuePairsLen%2 != 0 { 68 | panic("objx: MSI must have an even number of arguments following the 'key, value' pattern.") 69 | } 70 | 71 | for i := 0; i < keyAndValuePairsLen; i = i + 2 { 72 | 73 | key := keyAndValuePairs[i] 74 | value := keyAndValuePairs[i+1] 75 | 76 | // make sure the key is a string 77 | keyString, keyStringOK := key.(string) 78 | if !keyStringOK { 79 | panic("objx: MSI must follow 'string, interface{}' pattern. " + keyString + " is not a valid key.") 80 | } 81 | 82 | newMap[keyString] = value 83 | 84 | } 85 | 86 | return New(newMap) 87 | } 88 | 89 | // ****** Conversion Constructors 90 | 91 | // MustFromJSON creates a new Map containing the data specified in the 92 | // jsonString. 93 | // 94 | // Panics if the JSON is invalid. 95 | func MustFromJSON(jsonString string) Map { 96 | o, err := FromJSON(jsonString) 97 | 98 | if err != nil { 99 | panic("objx: MustFromJSON failed with error: " + err.Error()) 100 | } 101 | 102 | return o 103 | } 104 | 105 | // FromJSON creates a new Map containing the data specified in the 106 | // jsonString. 107 | // 108 | // Returns an error if the JSON is invalid. 109 | func FromJSON(jsonString string) (Map, error) { 110 | 111 | var data interface{} 112 | err := json.Unmarshal([]byte(jsonString), &data) 113 | 114 | if err != nil { 115 | return Nil, err 116 | } 117 | 118 | return New(data), nil 119 | 120 | } 121 | 122 | // FromBase64 creates a new Obj containing the data specified 123 | // in the Base64 string. 124 | // 125 | // The string is an encoded JSON string returned by Base64 126 | func FromBase64(base64String string) (Map, error) { 127 | 128 | decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(base64String)) 129 | 130 | decoded, err := ioutil.ReadAll(decoder) 131 | if err != nil { 132 | return nil, err 133 | } 134 | 135 | return FromJSON(string(decoded)) 136 | } 137 | 138 | // MustFromBase64 creates a new Obj containing the data specified 139 | // in the Base64 string and panics if there is an error. 140 | // 141 | // The string is an encoded JSON string returned by Base64 142 | func MustFromBase64(base64String string) Map { 143 | 144 | result, err := FromBase64(base64String) 145 | 146 | if err != nil { 147 | panic("objx: MustFromBase64 failed with error: " + err.Error()) 148 | } 149 | 150 | return result 151 | } 152 | 153 | // FromSignedBase64 creates a new Obj containing the data specified 154 | // in the Base64 string. 155 | // 156 | // The string is an encoded JSON string returned by SignedBase64 157 | func FromSignedBase64(base64String, key string) (Map, error) { 158 | parts := strings.Split(base64String, SignatureSeparator) 159 | if len(parts) != 2 { 160 | return nil, errors.New("objx: Signed base64 string is malformed.") 161 | } 162 | 163 | sig := HashWithKey(parts[0], key) 164 | if parts[1] != sig { 165 | return nil, errors.New("objx: Signature for base64 data does not match.") 166 | } 167 | 168 | return FromBase64(parts[0]) 169 | } 170 | 171 | // MustFromSignedBase64 creates a new Obj containing the data specified 172 | // in the Base64 string and panics if there is an error. 173 | // 174 | // The string is an encoded JSON string returned by Base64 175 | func MustFromSignedBase64(base64String, key string) Map { 176 | 177 | result, err := FromSignedBase64(base64String, key) 178 | 179 | if err != nil { 180 | panic("objx: MustFromSignedBase64 failed with error: " + err.Error()) 181 | } 182 | 183 | return result 184 | } 185 | 186 | // FromURLQuery generates a new Obj by parsing the specified 187 | // query. 188 | // 189 | // For queries with multiple values, the first value is selected. 190 | func FromURLQuery(query string) (Map, error) { 191 | 192 | vals, err := url.ParseQuery(query) 193 | 194 | if err != nil { 195 | return nil, err 196 | } 197 | 198 | m := make(map[string]interface{}) 199 | for k, vals := range vals { 200 | m[k] = vals[0] 201 | } 202 | 203 | return New(m), nil 204 | } 205 | 206 | // MustFromURLQuery generates a new Obj by parsing the specified 207 | // query. 208 | // 209 | // For queries with multiple values, the first value is selected. 210 | // 211 | // Panics if it encounters an error 212 | func MustFromURLQuery(query string) Map { 213 | 214 | o, err := FromURLQuery(query) 215 | 216 | if err != nil { 217 | panic("objx: MustFromURLQuery failed with error: " + err.Error()) 218 | } 219 | 220 | return o 221 | 222 | } 223 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/spew.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Dave Collins 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | package spew 18 | 19 | import ( 20 | "fmt" 21 | "io" 22 | ) 23 | 24 | // Errorf is a wrapper for fmt.Errorf that treats each argument as if it were 25 | // passed with a default Formatter interface returned by NewFormatter. It 26 | // returns the formatted string as a value that satisfies error. See 27 | // NewFormatter for formatting details. 28 | // 29 | // This function is shorthand for the following syntax: 30 | // 31 | // fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 32 | func Errorf(format string, a ...interface{}) (err error) { 33 | return fmt.Errorf(format, convertArgs(a)...) 34 | } 35 | 36 | // Fprint is a wrapper for fmt.Fprint that treats each argument as if it were 37 | // passed with a default Formatter interface returned by NewFormatter. It 38 | // returns the number of bytes written and any write error encountered. See 39 | // NewFormatter for formatting details. 40 | // 41 | // This function is shorthand for the following syntax: 42 | // 43 | // fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) 44 | func Fprint(w io.Writer, a ...interface{}) (n int, err error) { 45 | return fmt.Fprint(w, convertArgs(a)...) 46 | } 47 | 48 | // Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were 49 | // passed with a default Formatter interface returned by NewFormatter. It 50 | // returns the number of bytes written and any write error encountered. See 51 | // NewFormatter for formatting details. 52 | // 53 | // This function is shorthand for the following syntax: 54 | // 55 | // fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) 56 | func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { 57 | return fmt.Fprintf(w, format, convertArgs(a)...) 58 | } 59 | 60 | // Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it 61 | // passed with a default Formatter interface returned by NewFormatter. See 62 | // NewFormatter for formatting details. 63 | // 64 | // This function is shorthand for the following syntax: 65 | // 66 | // fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) 67 | func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { 68 | return fmt.Fprintln(w, convertArgs(a)...) 69 | } 70 | 71 | // Print is a wrapper for fmt.Print that treats each argument as if it were 72 | // passed with a default Formatter interface returned by NewFormatter. It 73 | // returns the number of bytes written and any write error encountered. See 74 | // NewFormatter for formatting details. 75 | // 76 | // This function is shorthand for the following syntax: 77 | // 78 | // fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) 79 | func Print(a ...interface{}) (n int, err error) { 80 | return fmt.Print(convertArgs(a)...) 81 | } 82 | 83 | // Printf is a wrapper for fmt.Printf that treats each argument as if it were 84 | // passed with a default Formatter interface returned by NewFormatter. It 85 | // returns the number of bytes written and any write error encountered. See 86 | // NewFormatter for formatting details. 87 | // 88 | // This function is shorthand for the following syntax: 89 | // 90 | // fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 91 | func Printf(format string, a ...interface{}) (n int, err error) { 92 | return fmt.Printf(format, convertArgs(a)...) 93 | } 94 | 95 | // Println is a wrapper for fmt.Println that treats each argument as if it were 96 | // passed with a default Formatter interface returned by NewFormatter. It 97 | // returns the number of bytes written and any write error encountered. See 98 | // NewFormatter for formatting details. 99 | // 100 | // This function is shorthand for the following syntax: 101 | // 102 | // fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) 103 | func Println(a ...interface{}) (n int, err error) { 104 | return fmt.Println(convertArgs(a)...) 105 | } 106 | 107 | // Sprint is a wrapper for fmt.Sprint that treats each argument as if it were 108 | // passed with a default Formatter interface returned by NewFormatter. It 109 | // returns the resulting string. See NewFormatter for formatting details. 110 | // 111 | // This function is shorthand for the following syntax: 112 | // 113 | // fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) 114 | func Sprint(a ...interface{}) string { 115 | return fmt.Sprint(convertArgs(a)...) 116 | } 117 | 118 | // Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were 119 | // passed with a default Formatter interface returned by NewFormatter. It 120 | // returns the resulting string. See NewFormatter for formatting details. 121 | // 122 | // This function is shorthand for the following syntax: 123 | // 124 | // fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 125 | func Sprintf(format string, a ...interface{}) string { 126 | return fmt.Sprintf(format, convertArgs(a)...) 127 | } 128 | 129 | // Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it 130 | // were passed with a default Formatter interface returned by NewFormatter. It 131 | // returns the resulting string. See NewFormatter for formatting details. 132 | // 133 | // This function is shorthand for the following syntax: 134 | // 135 | // fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) 136 | func Sprintln(a ...interface{}) string { 137 | return fmt.Sprintln(convertArgs(a)...) 138 | } 139 | 140 | // convertArgs accepts a slice of arguments and returns a slice of the same 141 | // length with each argument converted to a default spew Formatter interface. 142 | func convertArgs(args []interface{}) (formatters []interface{}) { 143 | formatters = make([]interface{}, len(args)) 144 | for index, arg := range args { 145 | formatters[index] = NewFormatter(arg) 146 | } 147 | return formatters 148 | } 149 | -------------------------------------------------------------------------------- /vendor/github.com/dghubble/sling/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package sling is a Go HTTP client library for creating and sending API requests. 3 | 4 | Slings store HTTP Request properties to simplify sending requests and decoding 5 | responses. Check the examples to learn how to compose a Sling into your API 6 | client. 7 | 8 | Usage 9 | 10 | Use a Sling to set path, method, header, query, or body properties and create an 11 | http.Request. 12 | 13 | type Params struct { 14 | Count int `url:"count,omitempty"` 15 | } 16 | params := &Params{Count: 5} 17 | 18 | req, err := sling.New().Get("https://example.com").QueryStruct(params).Request() 19 | client.Do(req) 20 | 21 | Path 22 | 23 | Use Path to set or extend the URL for created Requests. Extension means the 24 | path will be resolved relative to the existing URL. 25 | 26 | // creates a GET request to https://example.com/foo/bar 27 | req, err := sling.New().Base("https://example.com/").Path("foo/").Path("bar").Request() 28 | 29 | Use Get, Post, Put, Patch, Delete, or Head which are exactly the same as Path 30 | except they set the HTTP method too. 31 | 32 | req, err := sling.New().Post("http://upload.com/gophers") 33 | 34 | Headers 35 | 36 | Add or Set headers for requests created by a Sling. 37 | 38 | s := sling.New().Base(baseUrl).Set("User-Agent", "Gophergram API Client") 39 | req, err := s.New().Get("gophergram/list").Request() 40 | 41 | QueryStruct 42 | 43 | Define url parameter structs (https://godoc.org/github.com/google/go-querystring/query). 44 | Use QueryStruct to encode a struct as query parameters on requests. 45 | 46 | // Github Issue Parameters 47 | type IssueParams struct { 48 | Filter string `url:"filter,omitempty"` 49 | State string `url:"state,omitempty"` 50 | Labels string `url:"labels,omitempty"` 51 | Sort string `url:"sort,omitempty"` 52 | Direction string `url:"direction,omitempty"` 53 | Since string `url:"since,omitempty"` 54 | } 55 | 56 | githubBase := sling.New().Base("https://api.github.com/").Client(httpClient) 57 | 58 | path := fmt.Sprintf("repos/%s/%s/issues", owner, repo) 59 | params := &IssueParams{Sort: "updated", State: "open"} 60 | req, err := githubBase.New().Get(path).QueryStruct(params).Request() 61 | 62 | Json Body 63 | 64 | Define JSON tagged structs (https://golang.org/pkg/encoding/json/). 65 | Use BodyJSON to JSON encode a struct as the Body on requests. 66 | 67 | type IssueRequest struct { 68 | Title string `json:"title,omitempty"` 69 | Body string `json:"body,omitempty"` 70 | Assignee string `json:"assignee,omitempty"` 71 | Milestone int `json:"milestone,omitempty"` 72 | Labels []string `json:"labels,omitempty"` 73 | } 74 | 75 | githubBase := sling.New().Base("https://api.github.com/").Client(httpClient) 76 | path := fmt.Sprintf("repos/%s/%s/issues", owner, repo) 77 | 78 | body := &IssueRequest{ 79 | Title: "Test title", 80 | Body: "Some issue", 81 | } 82 | req, err := githubBase.New().Post(path).BodyJSON(body).Request() 83 | 84 | Requests will include an "application/json" Content-Type header. 85 | 86 | Form Body 87 | 88 | Define url tagged structs (https://godoc.org/github.com/google/go-querystring/query). 89 | Use BodyForm to form url encode a struct as the Body on requests. 90 | 91 | type StatusUpdateParams struct { 92 | Status string `url:"status,omitempty"` 93 | InReplyToStatusId int64 `url:"in_reply_to_status_id,omitempty"` 94 | MediaIds []int64 `url:"media_ids,omitempty,comma"` 95 | } 96 | 97 | tweetParams := &StatusUpdateParams{Status: "writing some Go"} 98 | req, err := twitterBase.New().Post(path).BodyForm(tweetParams).Request() 99 | 100 | Requests will include an "application/x-www-form-urlencoded" Content-Type 101 | header. 102 | 103 | Plain Body 104 | 105 | Use Body to set a plain io.Reader on requests created by a Sling. 106 | 107 | body := strings.NewReader("raw body") 108 | req, err := sling.New().Base("https://example.com").Body(body).Request() 109 | 110 | Set a content type header, if desired (e.g. Set("Content-Type", "text/plain")). 111 | 112 | Extend a Sling 113 | 114 | Each Sling generates an http.Request (say with some path and query params) 115 | each time Request() is called, based on its state. When creating 116 | different slings, you may wish to extend an existing Sling to minimize 117 | duplication (e.g. a common client). 118 | 119 | Each Sling instance provides a New() method which creates an independent copy, 120 | so setting properties on the child won't mutate the parent Sling. 121 | 122 | const twitterApi = "https://api.twitter.com/1.1/" 123 | base := sling.New().Base(twitterApi).Client(authClient) 124 | 125 | // statuses/show.json Sling 126 | tweetShowSling := base.New().Get("statuses/show.json").QueryStruct(params) 127 | req, err := tweetShowSling.Request() 128 | 129 | // statuses/update.json Sling 130 | tweetPostSling := base.New().Post("statuses/update.json").BodyForm(params) 131 | req, err := tweetPostSling.Request() 132 | 133 | Without the calls to base.New(), tweetShowSling and tweetPostSling would 134 | reference the base Sling and POST to 135 | "https://api.twitter.com/1.1/statuses/show.json/statuses/update.json", which 136 | is undesired. 137 | 138 | Recap: If you wish to extend a Sling, create a new child copy with New(). 139 | 140 | Receive 141 | 142 | Define a JSON struct to decode a type from 2XX success responses. Use 143 | ReceiveSuccess(successV interface{}) to send a new Request and decode the 144 | response body into successV if it succeeds. 145 | 146 | // Github Issue (abbreviated) 147 | type Issue struct { 148 | Title string `json:"title"` 149 | Body string `json:"body"` 150 | } 151 | 152 | issues := new([]Issue) 153 | resp, err := githubBase.New().Get(path).QueryStruct(params).ReceiveSuccess(issues) 154 | fmt.Println(issues, resp, err) 155 | 156 | Most APIs return failure responses with JSON error details. To decode these, 157 | define success and failure JSON structs. Use 158 | Receive(successV, failureV interface{}) to send a new Request that will 159 | automatically decode the response into the successV for 2XX responses or into 160 | failureV for non-2XX responses. 161 | 162 | type GithubError struct { 163 | Message string `json:"message"` 164 | Errors []struct { 165 | Resource string `json:"resource"` 166 | Field string `json:"field"` 167 | Code string `json:"code"` 168 | } `json:"errors"` 169 | DocumentationURL string `json:"documentation_url"` 170 | } 171 | 172 | issues := new([]Issue) 173 | githubError := new(GithubError) 174 | resp, err := githubBase.New().Get(path).QueryStruct(params).Receive(issues, githubError) 175 | fmt.Println(issues, githubError, resp, err) 176 | 177 | Pass a nil successV or failureV argument to skip JSON decoding into that value. 178 | */ 179 | package sling 180 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/client.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "net" 11 | "sync" 12 | ) 13 | 14 | // Client implements a traditional SSH client that supports shells, 15 | // subprocesses, port forwarding and tunneled dialing. 16 | type Client struct { 17 | Conn 18 | 19 | forwards forwardList // forwarded tcpip connections from the remote side 20 | mu sync.Mutex 21 | channelHandlers map[string]chan NewChannel 22 | } 23 | 24 | // HandleChannelOpen returns a channel on which NewChannel requests 25 | // for the given type are sent. If the type already is being handled, 26 | // nil is returned. The channel is closed when the connection is closed. 27 | func (c *Client) HandleChannelOpen(channelType string) <-chan NewChannel { 28 | c.mu.Lock() 29 | defer c.mu.Unlock() 30 | if c.channelHandlers == nil { 31 | // The SSH channel has been closed. 32 | c := make(chan NewChannel) 33 | close(c) 34 | return c 35 | } 36 | 37 | ch := c.channelHandlers[channelType] 38 | if ch != nil { 39 | return nil 40 | } 41 | 42 | ch = make(chan NewChannel, 16) 43 | c.channelHandlers[channelType] = ch 44 | return ch 45 | } 46 | 47 | // NewClient creates a Client on top of the given connection. 48 | func NewClient(c Conn, chans <-chan NewChannel, reqs <-chan *Request) *Client { 49 | conn := &Client{ 50 | Conn: c, 51 | channelHandlers: make(map[string]chan NewChannel, 1), 52 | } 53 | 54 | go conn.handleGlobalRequests(reqs) 55 | go conn.handleChannelOpens(chans) 56 | go func() { 57 | conn.Wait() 58 | conn.forwards.closeAll() 59 | }() 60 | go conn.forwards.handleChannels(conn.HandleChannelOpen("forwarded-tcpip")) 61 | return conn 62 | } 63 | 64 | // NewClientConn establishes an authenticated SSH connection using c 65 | // as the underlying transport. The Request and NewChannel channels 66 | // must be serviced or the connection will hang. 67 | func NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, <-chan NewChannel, <-chan *Request, error) { 68 | fullConf := *config 69 | fullConf.SetDefaults() 70 | conn := &connection{ 71 | sshConn: sshConn{conn: c}, 72 | } 73 | 74 | if err := conn.clientHandshake(addr, &fullConf); err != nil { 75 | c.Close() 76 | return nil, nil, nil, fmt.Errorf("ssh: handshake failed: %v", err) 77 | } 78 | conn.mux = newMux(conn.transport) 79 | return conn, conn.mux.incomingChannels, conn.mux.incomingRequests, nil 80 | } 81 | 82 | // clientHandshake performs the client side key exchange. See RFC 4253 Section 83 | // 7. 84 | func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) error { 85 | if config.ClientVersion != "" { 86 | c.clientVersion = []byte(config.ClientVersion) 87 | } else { 88 | c.clientVersion = []byte(packageVersion) 89 | } 90 | var err error 91 | c.serverVersion, err = exchangeVersions(c.sshConn.conn, c.clientVersion) 92 | if err != nil { 93 | return err 94 | } 95 | 96 | c.transport = newClientTransport( 97 | newTransport(c.sshConn.conn, config.Rand, true /* is client */), 98 | c.clientVersion, c.serverVersion, config, dialAddress, c.sshConn.RemoteAddr()) 99 | if err := c.transport.requestKeyChange(); err != nil { 100 | return err 101 | } 102 | 103 | if packet, err := c.transport.readPacket(); err != nil { 104 | return err 105 | } else if packet[0] != msgNewKeys { 106 | return unexpectedMessageError(msgNewKeys, packet[0]) 107 | } 108 | 109 | // We just did the key change, so the session ID is established. 110 | c.sessionID = c.transport.getSessionID() 111 | 112 | return c.clientAuthenticate(config) 113 | } 114 | 115 | // verifyHostKeySignature verifies the host key obtained in the key 116 | // exchange. 117 | func verifyHostKeySignature(hostKey PublicKey, result *kexResult) error { 118 | sig, rest, ok := parseSignatureBody(result.Signature) 119 | if len(rest) > 0 || !ok { 120 | return errors.New("ssh: signature parse error") 121 | } 122 | 123 | return hostKey.Verify(result.H, sig) 124 | } 125 | 126 | // NewSession opens a new Session for this client. (A session is a remote 127 | // execution of a program.) 128 | func (c *Client) NewSession() (*Session, error) { 129 | ch, in, err := c.OpenChannel("session", nil) 130 | if err != nil { 131 | return nil, err 132 | } 133 | return newSession(ch, in) 134 | } 135 | 136 | func (c *Client) handleGlobalRequests(incoming <-chan *Request) { 137 | for r := range incoming { 138 | // This handles keepalive messages and matches 139 | // the behaviour of OpenSSH. 140 | r.Reply(false, nil) 141 | } 142 | } 143 | 144 | // handleChannelOpens channel open messages from the remote side. 145 | func (c *Client) handleChannelOpens(in <-chan NewChannel) { 146 | for ch := range in { 147 | c.mu.Lock() 148 | handler := c.channelHandlers[ch.ChannelType()] 149 | c.mu.Unlock() 150 | 151 | if handler != nil { 152 | handler <- ch 153 | } else { 154 | ch.Reject(UnknownChannelType, fmt.Sprintf("unknown channel type: %v", ch.ChannelType())) 155 | } 156 | } 157 | 158 | c.mu.Lock() 159 | for _, ch := range c.channelHandlers { 160 | close(ch) 161 | } 162 | c.channelHandlers = nil 163 | c.mu.Unlock() 164 | } 165 | 166 | // Dial starts a client connection to the given SSH server. It is a 167 | // convenience function that connects to the given network address, 168 | // initiates the SSH handshake, and then sets up a Client. For access 169 | // to incoming channels and requests, use net.Dial with NewClientConn 170 | // instead. 171 | func Dial(network, addr string, config *ClientConfig) (*Client, error) { 172 | conn, err := net.Dial(network, addr) 173 | if err != nil { 174 | return nil, err 175 | } 176 | c, chans, reqs, err := NewClientConn(conn, addr, config) 177 | if err != nil { 178 | return nil, err 179 | } 180 | return NewClient(c, chans, reqs), nil 181 | } 182 | 183 | // A ClientConfig structure is used to configure a Client. It must not be 184 | // modified after having been passed to an SSH function. 185 | type ClientConfig struct { 186 | // Config contains configuration that is shared between clients and 187 | // servers. 188 | Config 189 | 190 | // User contains the username to authenticate as. 191 | User string 192 | 193 | // Auth contains possible authentication methods to use with the 194 | // server. Only the first instance of a particular RFC 4252 method will 195 | // be used during authentication. 196 | Auth []AuthMethod 197 | 198 | // HostKeyCallback, if not nil, is called during the cryptographic 199 | // handshake to validate the server's host key. A nil HostKeyCallback 200 | // implies that all host keys are accepted. 201 | HostKeyCallback func(hostname string, remote net.Addr, key PublicKey) error 202 | 203 | // ClientVersion contains the version identification string that will 204 | // be used for the connection. If empty, a reasonable default is used. 205 | ClientVersion string 206 | 207 | // HostKeyAlgorithms lists the key types that the client will 208 | // accept from the server as host key, in order of 209 | // preference. If empty, a reasonable default is used. Any 210 | // string returned from PublicKey.Type method may be used, or 211 | // any of the CertAlgoXxxx and KeyAlgoXxxx constants. 212 | HostKeyAlgorithms []string 213 | } 214 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/plugin/localbinary/plugin.go: -------------------------------------------------------------------------------- 1 | package localbinary 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "io" 7 | "os" 8 | "os/exec" 9 | "strings" 10 | "time" 11 | 12 | "github.com/docker/machine/libmachine/log" 13 | ) 14 | 15 | var ( 16 | // Timeout where we will bail if we're not able to properly contact the 17 | // plugin server. 18 | defaultTimeout = 10 * time.Second 19 | CurrentBinaryIsDockerMachine = false 20 | CoreDrivers = [...]string{"amazonec2", "azure", "digitalocean", 21 | "exoscale", "generic", "google", "hyperv", "none", "openstack", 22 | "rackspace", "softlayer", "virtualbox", "vmwarefusion", 23 | "vmwarevcloudair", "vmwarevsphere"} 24 | ) 25 | 26 | const ( 27 | pluginOut = "(%s) %s" 28 | pluginErr = "(%s) DBG | %s" 29 | PluginEnvKey = "MACHINE_PLUGIN_TOKEN" 30 | PluginEnvVal = "42" 31 | PluginEnvDriverName = "MACHINE_PLUGIN_DRIVER_NAME" 32 | ) 33 | 34 | type PluginStreamer interface { 35 | // Return a channel for receiving the output of the stream line by 36 | // line. 37 | // 38 | // It happens to be the case that we do this all inside of the main 39 | // plugin struct today, but that may not be the case forever. 40 | AttachStream(*bufio.Scanner) <-chan string 41 | } 42 | 43 | type PluginServer interface { 44 | // Get the address where the plugin server is listening. 45 | Address() (string, error) 46 | 47 | // Serve kicks off the plugin server. 48 | Serve() error 49 | 50 | // Close shuts down the initialized server. 51 | Close() error 52 | } 53 | 54 | type McnBinaryExecutor interface { 55 | // Execute the driver plugin. Returns scanners for plugin binary 56 | // stdout and stderr. 57 | Start() (*bufio.Scanner, *bufio.Scanner, error) 58 | 59 | // Stop reading from the plugins in question. 60 | Close() error 61 | } 62 | 63 | // DriverPlugin interface wraps the underlying mechanics of starting a driver 64 | // plugin server and then figuring out where it can be dialed. 65 | type DriverPlugin interface { 66 | PluginServer 67 | PluginStreamer 68 | } 69 | 70 | type Plugin struct { 71 | Executor McnBinaryExecutor 72 | Addr string 73 | MachineName string 74 | addrCh chan string 75 | stopCh chan bool 76 | timeout time.Duration 77 | } 78 | 79 | type Executor struct { 80 | pluginStdout, pluginStderr io.ReadCloser 81 | DriverName string 82 | cmd *exec.Cmd 83 | binaryPath string 84 | } 85 | 86 | type ErrPluginBinaryNotFound struct { 87 | driverName string 88 | } 89 | 90 | func (e ErrPluginBinaryNotFound) Error() string { 91 | return fmt.Sprintf("Driver %q not found. Do you have the plugin binary accessible in your PATH?", e.driverName) 92 | } 93 | 94 | // driverPath finds the path of a driver binary by its name. 95 | // + If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine` 96 | // or we assume `docker-machine` is in the PATH. 97 | // + If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be 98 | // `docker-machine-driver-driverName` 99 | func driverPath(driverName string) string { 100 | for _, coreDriver := range CoreDrivers { 101 | if coreDriver == driverName { 102 | if CurrentBinaryIsDockerMachine { 103 | return os.Args[0] 104 | } 105 | 106 | return "docker-machine" 107 | } 108 | } 109 | 110 | return fmt.Sprintf("docker-machine-driver-%s", driverName) 111 | } 112 | 113 | func NewPlugin(driverName string) (*Plugin, error) { 114 | driverPath := driverPath(driverName) 115 | binaryPath, err := exec.LookPath(driverPath) 116 | if err != nil { 117 | return nil, ErrPluginBinaryNotFound{driverName} 118 | } 119 | 120 | log.Debugf("Found binary path at %s", binaryPath) 121 | 122 | return &Plugin{ 123 | stopCh: make(chan bool), 124 | addrCh: make(chan string, 1), 125 | Executor: &Executor{ 126 | DriverName: driverName, 127 | binaryPath: binaryPath, 128 | }, 129 | }, nil 130 | } 131 | 132 | func (lbe *Executor) Start() (*bufio.Scanner, *bufio.Scanner, error) { 133 | var err error 134 | 135 | log.Debugf("Launching plugin server for driver %s", lbe.DriverName) 136 | 137 | lbe.cmd = exec.Command(lbe.binaryPath) 138 | 139 | lbe.pluginStdout, err = lbe.cmd.StdoutPipe() 140 | if err != nil { 141 | return nil, nil, fmt.Errorf("Error getting cmd stdout pipe: %s", err) 142 | } 143 | 144 | lbe.pluginStderr, err = lbe.cmd.StderrPipe() 145 | if err != nil { 146 | return nil, nil, fmt.Errorf("Error getting cmd stderr pipe: %s", err) 147 | } 148 | 149 | outScanner := bufio.NewScanner(lbe.pluginStdout) 150 | errScanner := bufio.NewScanner(lbe.pluginStderr) 151 | 152 | os.Setenv(PluginEnvKey, PluginEnvVal) 153 | os.Setenv(PluginEnvDriverName, lbe.DriverName) 154 | 155 | if err := lbe.cmd.Start(); err != nil { 156 | return nil, nil, fmt.Errorf("Error starting plugin binary: %s", err) 157 | } 158 | 159 | return outScanner, errScanner, nil 160 | } 161 | 162 | func (lbe *Executor) Close() error { 163 | if err := lbe.cmd.Wait(); err != nil { 164 | return fmt.Errorf("Error waiting for binary close: %s", err) 165 | } 166 | 167 | return nil 168 | } 169 | 170 | func stream(scanner *bufio.Scanner, streamOutCh chan<- string) { 171 | for scanner.Scan() { 172 | line := scanner.Text() 173 | if err := scanner.Err(); err != nil { 174 | log.Warnf("Scanning stream: %s", err) 175 | } 176 | streamOutCh <- strings.Trim(line, "\n") 177 | } 178 | } 179 | 180 | func (lbp *Plugin) AttachStream(scanner *bufio.Scanner) <-chan string { 181 | streamOutCh := make(chan string) 182 | go stream(scanner, streamOutCh) 183 | return streamOutCh 184 | } 185 | 186 | func (lbp *Plugin) execServer() error { 187 | outScanner, errScanner, err := lbp.Executor.Start() 188 | if err != nil { 189 | return err 190 | } 191 | 192 | // Scan just one line to get the address, then send it to the relevant 193 | // channel. 194 | outScanner.Scan() 195 | addr := outScanner.Text() 196 | if err := outScanner.Err(); err != nil { 197 | return fmt.Errorf("Reading plugin address failed: %s", err) 198 | } 199 | 200 | lbp.addrCh <- strings.TrimSpace(addr) 201 | 202 | stdOutCh := lbp.AttachStream(outScanner) 203 | stdErrCh := lbp.AttachStream(errScanner) 204 | 205 | for { 206 | select { 207 | case out := <-stdOutCh: 208 | log.Infof(pluginOut, lbp.MachineName, out) 209 | case err := <-stdErrCh: 210 | log.Debugf(pluginErr, lbp.MachineName, err) 211 | case <-lbp.stopCh: 212 | if err := lbp.Executor.Close(); err != nil { 213 | return fmt.Errorf("Error closing local plugin binary: %s", err) 214 | } 215 | return nil 216 | } 217 | } 218 | } 219 | 220 | func (lbp *Plugin) Serve() error { 221 | return lbp.execServer() 222 | } 223 | 224 | func (lbp *Plugin) Address() (string, error) { 225 | if lbp.Addr == "" { 226 | if lbp.timeout == 0 { 227 | lbp.timeout = defaultTimeout 228 | } 229 | 230 | select { 231 | case lbp.Addr = <-lbp.addrCh: 232 | log.Debugf("Plugin server listening at address %s", lbp.Addr) 233 | close(lbp.addrCh) 234 | return lbp.Addr, nil 235 | case <-time.After(lbp.timeout): 236 | return "", fmt.Errorf("Failed to dial the plugin server in %s", lbp.timeout) 237 | } 238 | } 239 | return lbp.Addr, nil 240 | } 241 | 242 | func (lbp *Plugin) Close() error { 243 | lbp.stopCh <- true 244 | return nil 245 | } 246 | -------------------------------------------------------------------------------- /vendor/github.com/google/go-querystring/query/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package query implements encoding of structs into URL query parameters. 6 | // 7 | // As a simple example: 8 | // 9 | // type Options struct { 10 | // Query string `url:"q"` 11 | // ShowAll bool `url:"all"` 12 | // Page int `url:"page"` 13 | // } 14 | // 15 | // opt := Options{ "foo", true, 2 } 16 | // v, _ := query.Values(opt) 17 | // fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" 18 | // 19 | // The exact mapping between Go values and url.Values is described in the 20 | // documentation for the Values() function. 21 | package query 22 | 23 | import ( 24 | "bytes" 25 | "errors" 26 | "fmt" 27 | "net/url" 28 | "reflect" 29 | "strconv" 30 | "strings" 31 | "time" 32 | ) 33 | 34 | var timeType = reflect.TypeOf(time.Time{}) 35 | 36 | var encoderType = reflect.TypeOf(new(Encoder)).Elem() 37 | 38 | // Encoder is an interface implemented by any type that wishes to encode 39 | // itself into URL values in a non-standard way. 40 | type Encoder interface { 41 | EncodeValues(v *url.Values) error 42 | } 43 | 44 | // Values returns the url.Values encoding of v. 45 | // 46 | // Values expects to be passed a struct, and traverses it recursively using the 47 | // following encoding rules. 48 | // 49 | // Each exported struct field is encoded as a URL parameter unless 50 | // 51 | // - the field's tag is "-", or 52 | // - the field is empty and its tag specifies the "omitempty" option 53 | // 54 | // The empty values are false, 0, any nil pointer or interface value, any array 55 | // slice, map, or string of length zero, and any time.Time that returns true 56 | // for IsZero(). 57 | // 58 | // The URL parameter name defaults to the struct field name but can be 59 | // specified in the struct field's tag value. The "url" key in the struct 60 | // field's tag value is the key name, followed by an optional comma and 61 | // options. For example: 62 | // 63 | // // Field is ignored by this package. 64 | // Field int `url:"-"` 65 | // 66 | // // Field appears as URL parameter "myName". 67 | // Field int `url:"myName"` 68 | // 69 | // // Field appears as URL parameter "myName" and the field is omitted if 70 | // // its value is empty 71 | // Field int `url:"myName,omitempty"` 72 | // 73 | // // Field appears as URL parameter "Field" (the default), but the field 74 | // // is skipped if empty. Note the leading comma. 75 | // Field int `url:",omitempty"` 76 | // 77 | // For encoding individual field values, the following type-dependent rules 78 | // apply: 79 | // 80 | // Boolean values default to encoding as the strings "true" or "false". 81 | // Including the "int" option signals that the field should be encoded as the 82 | // strings "1" or "0". 83 | // 84 | // time.Time values default to encoding as RFC3339 timestamps. Including the 85 | // "unix" option signals that the field should be encoded as a Unix time (see 86 | // time.Unix()) 87 | // 88 | // Slice and Array values default to encoding as multiple URL values of the 89 | // same name. Including the "comma" option signals that the field should be 90 | // encoded as a single comma-delimited value. Including the "space" option 91 | // similarly encodes the value as a single space-delimited string. 92 | // 93 | // Anonymous struct fields are usually encoded as if their inner exported 94 | // fields were fields in the outer struct, subject to the standard Go 95 | // visibility rules. An anonymous struct field with a name given in its URL 96 | // tag is treated as having that name, rather than being anonymous. 97 | // 98 | // Non-nil pointer values are encoded as the value pointed to. 99 | // 100 | // All other values are encoded using their default string representation. 101 | // 102 | // Multiple fields that encode to the same URL parameter name will be included 103 | // as multiple URL values of the same name. 104 | func Values(v interface{}) (url.Values, error) { 105 | val := reflect.ValueOf(v) 106 | for val.Kind() == reflect.Ptr { 107 | if val.IsNil() { 108 | return nil, errors.New("query: Values() expects non-nil value") 109 | } 110 | val = val.Elem() 111 | } 112 | 113 | if val.Kind() != reflect.Struct { 114 | return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) 115 | } 116 | 117 | values := make(url.Values) 118 | err := reflectValue(values, val) 119 | return values, err 120 | } 121 | 122 | // reflectValue populates the values parameter from the struct fields in val. 123 | // Embedded structs are followed recursively (using the rules defined in the 124 | // Values function documentation) breadth-first. 125 | func reflectValue(values url.Values, val reflect.Value) error { 126 | var embedded []reflect.Value 127 | 128 | typ := val.Type() 129 | for i := 0; i < typ.NumField(); i++ { 130 | sf := typ.Field(i) 131 | if sf.PkgPath != "" { // unexported 132 | continue 133 | } 134 | 135 | sv := val.Field(i) 136 | tag := sf.Tag.Get("url") 137 | if tag == "-" { 138 | continue 139 | } 140 | name, opts := parseTag(tag) 141 | if name == "" { 142 | if sf.Anonymous && sv.Kind() == reflect.Struct { 143 | // save embedded struct for later processing 144 | embedded = append(embedded, sv) 145 | continue 146 | } 147 | 148 | name = sf.Name 149 | } 150 | 151 | if opts.Contains("omitempty") && isEmptyValue(sv) { 152 | continue 153 | } 154 | 155 | if sv.Type().Implements(encoderType) { 156 | m := sv.Interface().(Encoder) 157 | if err := m.EncodeValues(&values); err != nil { 158 | return err 159 | } 160 | continue 161 | } 162 | 163 | if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { 164 | var del byte 165 | if opts.Contains("comma") { 166 | del = ',' 167 | } else if opts.Contains("space") { 168 | del = ' ' 169 | } 170 | 171 | if del != 0 { 172 | s := new(bytes.Buffer) 173 | first := true 174 | for i := 0; i < sv.Len(); i++ { 175 | if first { 176 | first = false 177 | } else { 178 | s.WriteByte(del) 179 | } 180 | s.WriteString(valueString(sv.Index(i), opts)) 181 | } 182 | values.Add(name, s.String()) 183 | } else { 184 | for i := 0; i < sv.Len(); i++ { 185 | values.Add(name, valueString(sv.Index(i), opts)) 186 | } 187 | } 188 | continue 189 | } 190 | 191 | values.Add(name, valueString(sv, opts)) 192 | } 193 | 194 | for _, f := range embedded { 195 | if err := reflectValue(values, f); err != nil { 196 | return err 197 | } 198 | } 199 | 200 | return nil 201 | } 202 | 203 | // valueString returns the string representation of a value. 204 | func valueString(v reflect.Value, opts tagOptions) string { 205 | for v.Kind() == reflect.Ptr { 206 | if v.IsNil() { 207 | return "" 208 | } 209 | v = v.Elem() 210 | } 211 | 212 | if v.Kind() == reflect.Bool && opts.Contains("int") { 213 | if v.Bool() { 214 | return "1" 215 | } 216 | return "0" 217 | } 218 | 219 | if v.Type() == timeType { 220 | t := v.Interface().(time.Time) 221 | if opts.Contains("unix") { 222 | return strconv.FormatInt(t.Unix(), 10) 223 | } 224 | return t.Format(time.RFC3339) 225 | } 226 | 227 | return fmt.Sprint(v.Interface()) 228 | } 229 | 230 | // isEmptyValue checks if a value should be considered empty for the purposes 231 | // of omitting fields with the "omitempty" option. 232 | func isEmptyValue(v reflect.Value) bool { 233 | switch v.Kind() { 234 | case reflect.Array, reflect.Map, reflect.Slice, reflect.String: 235 | return v.Len() == 0 236 | case reflect.Bool: 237 | return !v.Bool() 238 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 239 | return v.Int() == 0 240 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 241 | return v.Uint() == 0 242 | case reflect.Float32, reflect.Float64: 243 | return v.Float() == 0 244 | case reflect.Interface, reflect.Ptr: 245 | return v.IsNil() 246 | } 247 | 248 | if v.Type() == timeType { 249 | return v.Interface().(time.Time).IsZero() 250 | } 251 | 252 | return false 253 | } 254 | 255 | // tagOptions is the string following a comma in a struct field's "url" tag, or 256 | // the empty string. It does not include the leading comma. 257 | type tagOptions []string 258 | 259 | // parseTag splits a struct field's url tag into its name and comma-separated 260 | // options. 261 | func parseTag(tag string) (string, tagOptions) { 262 | s := strings.Split(tag, ",") 263 | return s[0], s[1:] 264 | } 265 | 266 | // Contains checks whether the tagOptions contains the specified option. 267 | func (o tagOptions) Contains(option string) bool { 268 | for _, s := range o { 269 | if s == option { 270 | return true 271 | } 272 | } 273 | return false 274 | } 275 | --------------------------------------------------------------------------------