├── .gitignore ├── Dockerfile ├── Dockerfile.dev ├── Godeps ├── Godeps.json ├── Readme └── _workspace │ ├── .gitignore │ └── src │ ├── github.com │ ├── BurntSushi │ │ └── toml │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── COMPATIBLE │ │ │ ├── COPYING │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── decode.go │ │ │ ├── decode_meta.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── encoding_types.go │ │ │ ├── encoding_types_1.1.go │ │ │ ├── lex.go │ │ │ ├── parse.go │ │ │ ├── session.vim │ │ │ ├── type_check.go │ │ │ └── type_fields.go │ ├── Sirupsen │ │ └── logrus │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── entry.go │ │ │ ├── exported.go │ │ │ ├── formatter.go │ │ │ ├── hooks.go │ │ │ ├── json_formatter.go │ │ │ ├── logger.go │ │ │ ├── logrus.go │ │ │ ├── terminal_bsd.go │ │ │ ├── terminal_linux.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_solaris.go │ │ │ ├── terminal_windows.go │ │ │ ├── text_formatter.go │ │ │ └── writer.go │ └── rancher │ │ └── go-rancher-metadata │ │ └── metadata │ │ ├── change.go │ │ ├── metadata.go │ │ ├── types.go │ │ └── utils.go │ └── golang.org │ └── x │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── circle.yml ├── config.go ├── examples └── config.toml.sample ├── main.go ├── runner.go ├── scripts └── vet ├── template_context.go ├── template_functions.go └── template_types.go /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /build 3 | /dist 4 | /artifacts 5 | /test 6 | rancher-gen 7 | secrets.txt 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | MAINTAINER 3 | 4 | RUN apk add --no-cache ca-certificates 5 | 6 | ENV RANCHER_GEN_RELEASE v0.2.0 7 | 8 | ADD https://github.com/janeczku/go-rancher-gen/releases/download/${RANCHER_GEN_RELEASE}/rancher-gen-linux-amd64.tar.gz /tmp/rancher-gen.tar.gz 9 | RUN tar -zxvf /tmp/rancher-gen.tar.gz -C /usr/local/bin \ 10 | && chmod +x /usr/local/bin/rancher-gen 11 | 12 | ENTRYPOINT ["/usr/local/bin/rancher-gen"] -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | MAINTAINER Jan Broer 3 | 4 | RUN apk add --no-cache ca-certificates 5 | 6 | ADD build/rancher-gen-linux-amd64 /usr/local/bin/rancher-gen 7 | RUN chmod +x /usr/local/bin/rancher-gen 8 | 9 | COPY ./test /etc/rancher-gen/ 10 | 11 | ENTRYPOINT ["/usr/local/bin/rancher-gen"] 12 | CMD ["--config", "/etc/rancher-gen/config.toml"] -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/janeczku/rancher-gen", 3 | "GoVersion": "go1.5", 4 | "GodepVersion": "v70", 5 | "Deps": [ 6 | { 7 | "ImportPath": "github.com/BurntSushi/toml", 8 | "Comment": "v0.2.0-21-g9906417", 9 | "Rev": "99064174e013895bbd9b025c31100bd1d9b590ca" 10 | }, 11 | { 12 | "ImportPath": "github.com/Sirupsen/logrus", 13 | "Comment": "v0.10.0", 14 | "Rev": "4b6ea7319e214d98c938f12692336f7ca9348d6b" 15 | }, 16 | { 17 | "ImportPath": "github.com/rancher/go-rancher-metadata/metadata", 18 | "Rev": "1e18111ea0df2484398d7c96bb21b6f27f975311" 19 | }, 20 | { 21 | "ImportPath": "golang.org/x/sys/unix", 22 | "Rev": "30de6d19a3bd89a5f38ae4028e23aaa5582648af" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - 1.6 9 | - tip 10 | install: 11 | - go install ./... 12 | - go get github.com/BurntSushi/toml-test 13 | script: 14 | - export PATH="$PATH:$HOME/gopath/bin" 15 | - make test 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 3 | 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/README.md: -------------------------------------------------------------------------------- 1 | ## TOML parser and encoder for Go with reflection 2 | 3 | TOML stands for Tom's Obvious, Minimal Language. This Go package provides a 4 | reflection interface similar to Go's standard library `json` and `xml` 5 | packages. This package also supports the `encoding.TextUnmarshaler` and 6 | `encoding.TextMarshaler` interfaces so that you can define custom data 7 | representations. (There is an example of this below.) 8 | 9 | Spec: https://github.com/mojombo/toml 10 | 11 | Compatible with TOML version 12 | [v0.2.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.2.0.md) 13 | 14 | Documentation: http://godoc.org/github.com/BurntSushi/toml 15 | 16 | Installation: 17 | 18 | ```bash 19 | go get github.com/BurntSushi/toml 20 | ``` 21 | 22 | Try the toml validator: 23 | 24 | ```bash 25 | go get github.com/BurntSushi/toml/cmd/tomlv 26 | tomlv some-toml-file.toml 27 | ``` 28 | 29 | [![Build status](https://api.travis-ci.org/BurntSushi/toml.png)](https://travis-ci.org/BurntSushi/toml) 30 | 31 | 32 | ### Testing 33 | 34 | This package passes all tests in 35 | [toml-test](https://github.com/BurntSushi/toml-test) for both the decoder 36 | and the encoder. 37 | 38 | ### Examples 39 | 40 | This package works similarly to how the Go standard library handles `XML` 41 | and `JSON`. Namely, data is loaded into Go values via reflection. 42 | 43 | For the simplest example, consider some TOML file as just a list of keys 44 | and values: 45 | 46 | ```toml 47 | Age = 25 48 | Cats = [ "Cauchy", "Plato" ] 49 | Pi = 3.14 50 | Perfection = [ 6, 28, 496, 8128 ] 51 | DOB = 1987-07-05T05:45:00Z 52 | ``` 53 | 54 | Which could be defined in Go as: 55 | 56 | ```go 57 | type Config struct { 58 | Age int 59 | Cats []string 60 | Pi float64 61 | Perfection []int 62 | DOB time.Time // requires `import time` 63 | } 64 | ``` 65 | 66 | And then decoded with: 67 | 68 | ```go 69 | var conf Config 70 | if _, err := toml.Decode(tomlData, &conf); err != nil { 71 | // handle error 72 | } 73 | ``` 74 | 75 | You can also use struct tags if your struct field name doesn't map to a TOML 76 | key value directly: 77 | 78 | ```toml 79 | some_key_NAME = "wat" 80 | ``` 81 | 82 | ```go 83 | type TOML struct { 84 | ObscureKey string `toml:"some_key_NAME"` 85 | } 86 | ``` 87 | 88 | ### Using the `encoding.TextUnmarshaler` interface 89 | 90 | Here's an example that automatically parses duration strings into 91 | `time.Duration` values: 92 | 93 | ```toml 94 | [[song]] 95 | name = "Thunder Road" 96 | duration = "4m49s" 97 | 98 | [[song]] 99 | name = "Stairway to Heaven" 100 | duration = "8m03s" 101 | ``` 102 | 103 | Which can be decoded with: 104 | 105 | ```go 106 | type song struct { 107 | Name string 108 | Duration duration 109 | } 110 | type songs struct { 111 | Song []song 112 | } 113 | var favorites songs 114 | if _, err := toml.Decode(blob, &favorites); err != nil { 115 | log.Fatal(err) 116 | } 117 | 118 | for _, s := range favorites.Song { 119 | fmt.Printf("%s (%s)\n", s.Name, s.Duration) 120 | } 121 | ``` 122 | 123 | And you'll also need a `duration` type that satisfies the 124 | `encoding.TextUnmarshaler` interface: 125 | 126 | ```go 127 | type duration struct { 128 | time.Duration 129 | } 130 | 131 | func (d *duration) UnmarshalText(text []byte) error { 132 | var err error 133 | d.Duration, err = time.ParseDuration(string(text)) 134 | return err 135 | } 136 | ``` 137 | 138 | ### More complex usage 139 | 140 | Here's an example of how to load the example from the official spec page: 141 | 142 | ```toml 143 | # This is a TOML document. Boom. 144 | 145 | title = "TOML Example" 146 | 147 | [owner] 148 | name = "Tom Preston-Werner" 149 | organization = "GitHub" 150 | bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." 151 | dob = 1979-05-27T07:32:00Z # First class dates? Why not? 152 | 153 | [database] 154 | server = "192.168.1.1" 155 | ports = [ 8001, 8001, 8002 ] 156 | connection_max = 5000 157 | enabled = true 158 | 159 | [servers] 160 | 161 | # You can indent as you please. Tabs or spaces. TOML don't care. 162 | [servers.alpha] 163 | ip = "10.0.0.1" 164 | dc = "eqdc10" 165 | 166 | [servers.beta] 167 | ip = "10.0.0.2" 168 | dc = "eqdc10" 169 | 170 | [clients] 171 | data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it 172 | 173 | # Line breaks are OK when inside arrays 174 | hosts = [ 175 | "alpha", 176 | "omega" 177 | ] 178 | ``` 179 | 180 | And the corresponding Go types are: 181 | 182 | ```go 183 | type tomlConfig struct { 184 | Title string 185 | Owner ownerInfo 186 | DB database `toml:"database"` 187 | Servers map[string]server 188 | Clients clients 189 | } 190 | 191 | type ownerInfo struct { 192 | Name string 193 | Org string `toml:"organization"` 194 | Bio string 195 | DOB time.Time 196 | } 197 | 198 | type database struct { 199 | Server string 200 | Ports []int 201 | ConnMax int `toml:"connection_max"` 202 | Enabled bool 203 | } 204 | 205 | type server struct { 206 | IP string 207 | DC string 208 | } 209 | 210 | type clients struct { 211 | Data [][]interface{} 212 | Hosts []string 213 | } 214 | ``` 215 | 216 | Note that a case insensitive match will be tried if an exact match can't be 217 | found. 218 | 219 | A working example of the above can be found in `_examples/example.{go,toml}`. 220 | 221 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/decode_meta.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import "strings" 4 | 5 | // MetaData allows access to meta information about TOML data that may not 6 | // be inferrable via reflection. In particular, whether a key has been defined 7 | // and the TOML type of a key. 8 | type MetaData struct { 9 | mapping map[string]interface{} 10 | types map[string]tomlType 11 | keys []Key 12 | decoded map[string]bool 13 | context Key // Used only during decoding. 14 | } 15 | 16 | // IsDefined returns true if the key given exists in the TOML data. The key 17 | // should be specified hierarchially. e.g., 18 | // 19 | // // access the TOML key 'a.b.c' 20 | // IsDefined("a", "b", "c") 21 | // 22 | // IsDefined will return false if an empty key given. Keys are case sensitive. 23 | func (md *MetaData) IsDefined(key ...string) bool { 24 | if len(key) == 0 { 25 | return false 26 | } 27 | 28 | var hash map[string]interface{} 29 | var ok bool 30 | var hashOrVal interface{} = md.mapping 31 | for _, k := range key { 32 | if hash, ok = hashOrVal.(map[string]interface{}); !ok { 33 | return false 34 | } 35 | if hashOrVal, ok = hash[k]; !ok { 36 | return false 37 | } 38 | } 39 | return true 40 | } 41 | 42 | // Type returns a string representation of the type of the key specified. 43 | // 44 | // Type will return the empty string if given an empty key or a key that 45 | // does not exist. Keys are case sensitive. 46 | func (md *MetaData) Type(key ...string) string { 47 | fullkey := strings.Join(key, ".") 48 | if typ, ok := md.types[fullkey]; ok { 49 | return typ.typeString() 50 | } 51 | return "" 52 | } 53 | 54 | // Key is the type of any TOML key, including key groups. Use (MetaData).Keys 55 | // to get values of this type. 56 | type Key []string 57 | 58 | func (k Key) String() string { 59 | return strings.Join(k, ".") 60 | } 61 | 62 | func (k Key) maybeQuotedAll() string { 63 | var ss []string 64 | for i := range k { 65 | ss = append(ss, k.maybeQuoted(i)) 66 | } 67 | return strings.Join(ss, ".") 68 | } 69 | 70 | func (k Key) maybeQuoted(i int) string { 71 | quote := false 72 | for _, c := range k[i] { 73 | if !isBareKeyChar(c) { 74 | quote = true 75 | break 76 | } 77 | } 78 | if quote { 79 | return "\"" + strings.Replace(k[i], "\"", "\\\"", -1) + "\"" 80 | } 81 | return k[i] 82 | } 83 | 84 | func (k Key) add(piece string) Key { 85 | newKey := make(Key, len(k)+1) 86 | copy(newKey, k) 87 | newKey[len(k)] = piece 88 | return newKey 89 | } 90 | 91 | // Keys returns a slice of every key in the TOML data, including key groups. 92 | // Each key is itself a slice, where the first element is the top of the 93 | // hierarchy and the last is the most specific. 94 | // 95 | // The list will have the same order as the keys appeared in the TOML data. 96 | // 97 | // All keys returned are non-empty. 98 | func (md *MetaData) Keys() []Key { 99 | return md.keys 100 | } 101 | 102 | // Undecoded returns all keys that have not been decoded in the order in which 103 | // they appear in the original TOML document. 104 | // 105 | // This includes keys that haven't been decoded because of a Primitive value. 106 | // Once the Primitive value is decoded, the keys will be considered decoded. 107 | // 108 | // Also note that decoding into an empty interface will result in no decoding, 109 | // and so no keys will be considered decoded. 110 | // 111 | // In this sense, the Undecoded keys correspond to keys in the TOML document 112 | // that do not have a concrete type in your representation. 113 | func (md *MetaData) Undecoded() []Key { 114 | undecoded := make([]Key, 0, len(md.keys)) 115 | for _, key := range md.keys { 116 | if !md.decoded[key.String()] { 117 | undecoded = append(undecoded, key) 118 | } 119 | } 120 | return undecoded 121 | } 122 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/mojombo/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/BurntSushi/toml/type_check.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsHash(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { 26 | return string(btype) 27 | } 28 | 29 | func (btype tomlBaseType) String() string { 30 | return btype.typeString() 31 | } 32 | 33 | var ( 34 | tomlInteger tomlBaseType = "Integer" 35 | tomlFloat tomlBaseType = "Float" 36 | tomlDatetime tomlBaseType = "Datetime" 37 | tomlString tomlBaseType = "String" 38 | tomlBool tomlBaseType = "Bool" 39 | tomlArray tomlBaseType = "Array" 40 | tomlHash tomlBaseType = "Hash" 41 | tomlArrayHash tomlBaseType = "ArrayHash" 42 | ) 43 | 44 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 45 | // Primitive values are: Integer, Float, Datetime, String and Bool. 46 | // 47 | // Passing a lexer item other than the following will cause a BUG message 48 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 49 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 50 | switch lexItem.typ { 51 | case itemInteger: 52 | return tomlInteger 53 | case itemFloat: 54 | return tomlFloat 55 | case itemDatetime: 56 | return tomlDatetime 57 | case itemString: 58 | return tomlString 59 | case itemMultilineString: 60 | return tomlString 61 | case itemRawString: 62 | return tomlString 63 | case itemRawMultilineString: 64 | return tomlString 65 | case itemBool: 66 | return tomlBool 67 | } 68 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 69 | panic("unreachable") 70 | } 71 | 72 | // typeOfArray returns a tomlType for an array given a list of types of its 73 | // values. 74 | // 75 | // In the current spec, if an array is homogeneous, then its type is always 76 | // "Array". If the array is not homogeneous, an error is generated. 77 | func (p *parser) typeOfArray(types []tomlType) tomlType { 78 | // Empty arrays are cool. 79 | if len(types) == 0 { 80 | return tomlArray 81 | } 82 | 83 | theType := types[0] 84 | for _, t := range types[1:] { 85 | if !typeEqual(theType, t) { 86 | p.panicf("Array contains values of type '%s' and '%s', but "+ 87 | "arrays must be homogeneous.", theType, t) 88 | } 89 | } 90 | return tomlArray 91 | } 92 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3 4 | - 1.4 5 | - 1.5 6 | - tip 7 | install: 8 | - go get -t ./... 9 | script: GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v ./... 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.10.0 2 | 3 | * feature: Add a test hook (#180) 4 | * feature: `ParseLevel` is now case-insensitive (#326) 5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308) 6 | * performance: avoid re-allocations on `WithFields` (#335) 7 | 8 | # 0.9.0 9 | 10 | * logrus/text_formatter: don't emit empty msg 11 | * logrus/hooks/airbrake: move out of main repository 12 | * logrus/hooks/sentry: move out of main repository 13 | * logrus/hooks/papertrail: move out of main repository 14 | * logrus/hooks/bugsnag: move out of main repository 15 | * logrus/core: run tests with `-race` 16 | * logrus/core: detect TTY based on `stderr` 17 | * logrus/core: support `WithError` on logger 18 | * logrus/core: Solaris support 19 | 20 | # 0.8.7 21 | 22 | * logrus/core: fix possible race (#216) 23 | * logrus/doc: small typo fixes and doc improvements 24 | 25 | 26 | # 0.8.6 27 | 28 | * hooks/raven: allow passing an initialized client 29 | 30 | # 0.8.5 31 | 32 | * logrus/core: revert #208 33 | 34 | # 0.8.4 35 | 36 | * formatter/text: fix data race (#218) 37 | 38 | # 0.8.3 39 | 40 | * logrus/core: fix entry log level (#208) 41 | * logrus/core: improve performance of text formatter by 40% 42 | * logrus/core: expose `LevelHooks` type 43 | * logrus/core: add support for DragonflyBSD and NetBSD 44 | * formatter/text: print structs more verbosely 45 | 46 | # 0.8.2 47 | 48 | * logrus: fix more Fatal family functions 49 | 50 | # 0.8.1 51 | 52 | * logrus: fix not exiting on `Fatalf` and `Fatalln` 53 | 54 | # 0.8.0 55 | 56 | * logrus: defaults to stderr instead of stdout 57 | * hooks/sentry: add special field for `*http.Request` 58 | * formatter/text: ignore Windows for colors 59 | 60 | # 0.7.3 61 | 62 | * formatter/\*: allow configuration of timestamp layout 63 | 64 | # 0.7.2 65 | 66 | * formatter/text: Add configuration option for time format (#158) 67 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 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. 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/exported.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | var ( 8 | // std is the name of the standard logger in stdlib `log` 9 | std = New() 10 | ) 11 | 12 | func StandardLogger() *Logger { 13 | return std 14 | } 15 | 16 | // SetOutput sets the standard logger output. 17 | func SetOutput(out io.Writer) { 18 | std.mu.Lock() 19 | defer std.mu.Unlock() 20 | std.Out = out 21 | } 22 | 23 | // SetFormatter sets the standard logger formatter. 24 | func SetFormatter(formatter Formatter) { 25 | std.mu.Lock() 26 | defer std.mu.Unlock() 27 | std.Formatter = formatter 28 | } 29 | 30 | // SetLevel sets the standard logger level. 31 | func SetLevel(level Level) { 32 | std.mu.Lock() 33 | defer std.mu.Unlock() 34 | std.Level = level 35 | } 36 | 37 | // GetLevel returns the standard logger level. 38 | func GetLevel() Level { 39 | std.mu.Lock() 40 | defer std.mu.Unlock() 41 | return std.Level 42 | } 43 | 44 | // AddHook adds a hook to the standard logger hooks. 45 | func AddHook(hook Hook) { 46 | std.mu.Lock() 47 | defer std.mu.Unlock() 48 | std.Hooks.Add(hook) 49 | } 50 | 51 | // WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. 52 | func WithError(err error) *Entry { 53 | return std.WithField(ErrorKey, err) 54 | } 55 | 56 | // WithField creates an entry from the standard logger and adds a field to 57 | // it. If you want multiple fields, use `WithFields`. 58 | // 59 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 60 | // or Panic on the Entry it returns. 61 | func WithField(key string, value interface{}) *Entry { 62 | return std.WithField(key, value) 63 | } 64 | 65 | // WithFields creates an entry from the standard logger and adds multiple 66 | // fields to it. This is simply a helper for `WithField`, invoking it 67 | // once for each field. 68 | // 69 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 70 | // or Panic on the Entry it returns. 71 | func WithFields(fields Fields) *Entry { 72 | return std.WithFields(fields) 73 | } 74 | 75 | // Debug logs a message at level Debug on the standard logger. 76 | func Debug(args ...interface{}) { 77 | std.Debug(args...) 78 | } 79 | 80 | // Print logs a message at level Info on the standard logger. 81 | func Print(args ...interface{}) { 82 | std.Print(args...) 83 | } 84 | 85 | // Info logs a message at level Info on the standard logger. 86 | func Info(args ...interface{}) { 87 | std.Info(args...) 88 | } 89 | 90 | // Warn logs a message at level Warn on the standard logger. 91 | func Warn(args ...interface{}) { 92 | std.Warn(args...) 93 | } 94 | 95 | // Warning logs a message at level Warn on the standard logger. 96 | func Warning(args ...interface{}) { 97 | std.Warning(args...) 98 | } 99 | 100 | // Error logs a message at level Error on the standard logger. 101 | func Error(args ...interface{}) { 102 | std.Error(args...) 103 | } 104 | 105 | // Panic logs a message at level Panic on the standard logger. 106 | func Panic(args ...interface{}) { 107 | std.Panic(args...) 108 | } 109 | 110 | // Fatal logs a message at level Fatal on the standard logger. 111 | func Fatal(args ...interface{}) { 112 | std.Fatal(args...) 113 | } 114 | 115 | // Debugf logs a message at level Debug on the standard logger. 116 | func Debugf(format string, args ...interface{}) { 117 | std.Debugf(format, args...) 118 | } 119 | 120 | // Printf logs a message at level Info on the standard logger. 121 | func Printf(format string, args ...interface{}) { 122 | std.Printf(format, args...) 123 | } 124 | 125 | // Infof logs a message at level Info on the standard logger. 126 | func Infof(format string, args ...interface{}) { 127 | std.Infof(format, args...) 128 | } 129 | 130 | // Warnf logs a message at level Warn on the standard logger. 131 | func Warnf(format string, args ...interface{}) { 132 | std.Warnf(format, args...) 133 | } 134 | 135 | // Warningf logs a message at level Warn on the standard logger. 136 | func Warningf(format string, args ...interface{}) { 137 | std.Warningf(format, args...) 138 | } 139 | 140 | // Errorf logs a message at level Error on the standard logger. 141 | func Errorf(format string, args ...interface{}) { 142 | std.Errorf(format, args...) 143 | } 144 | 145 | // Panicf logs a message at level Panic on the standard logger. 146 | func Panicf(format string, args ...interface{}) { 147 | std.Panicf(format, args...) 148 | } 149 | 150 | // Fatalf logs a message at level Fatal on the standard logger. 151 | func Fatalf(format string, args ...interface{}) { 152 | std.Fatalf(format, args...) 153 | } 154 | 155 | // Debugln logs a message at level Debug on the standard logger. 156 | func Debugln(args ...interface{}) { 157 | std.Debugln(args...) 158 | } 159 | 160 | // Println logs a message at level Info on the standard logger. 161 | func Println(args ...interface{}) { 162 | std.Println(args...) 163 | } 164 | 165 | // Infoln logs a message at level Info on the standard logger. 166 | func Infoln(args ...interface{}) { 167 | std.Infoln(args...) 168 | } 169 | 170 | // Warnln logs a message at level Warn on the standard logger. 171 | func Warnln(args ...interface{}) { 172 | std.Warnln(args...) 173 | } 174 | 175 | // Warningln logs a message at level Warn on the standard logger. 176 | func Warningln(args ...interface{}) { 177 | std.Warningln(args...) 178 | } 179 | 180 | // Errorln logs a message at level Error on the standard logger. 181 | func Errorln(args ...interface{}) { 182 | std.Errorln(args...) 183 | } 184 | 185 | // Panicln logs a message at level Panic on the standard logger. 186 | func Panicln(args ...interface{}) { 187 | std.Panicln(args...) 188 | } 189 | 190 | // Fatalln logs a message at level Fatal on the standard logger. 191 | func Fatalln(args ...interface{}) { 192 | std.Fatalln(args...) 193 | } 194 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/logger.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "sync" 7 | ) 8 | 9 | type Logger struct { 10 | // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a 11 | // file, or leave it default which is `os.Stderr`. You can also set this to 12 | // something more adventorous, such as logging to Kafka. 13 | Out io.Writer 14 | // Hooks for the logger instance. These allow firing events based on logging 15 | // levels and log entries. For example, to send errors to an error tracking 16 | // service, log to StatsD or dump the core on fatal errors. 17 | Hooks LevelHooks 18 | // All log entries pass through the formatter before logged to Out. The 19 | // included formatters are `TextFormatter` and `JSONFormatter` for which 20 | // TextFormatter is the default. In development (when a TTY is attached) it 21 | // logs with colors, but to a file it wouldn't. You can easily implement your 22 | // own that implements the `Formatter` interface, see the `README` or included 23 | // formatters for examples. 24 | Formatter Formatter 25 | // The logging level the logger should log at. This is typically (and defaults 26 | // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be 27 | // logged. `logrus.Debug` is useful in 28 | Level Level 29 | // Used to sync writing to the log. 30 | mu sync.Mutex 31 | } 32 | 33 | // Creates a new logger. Configuration should be set by changing `Formatter`, 34 | // `Out` and `Hooks` directly on the default logger instance. You can also just 35 | // instantiate your own: 36 | // 37 | // var log = &Logger{ 38 | // Out: os.Stderr, 39 | // Formatter: new(JSONFormatter), 40 | // Hooks: make(LevelHooks), 41 | // Level: logrus.DebugLevel, 42 | // } 43 | // 44 | // It's recommended to make this a global instance called `log`. 45 | func New() *Logger { 46 | return &Logger{ 47 | Out: os.Stderr, 48 | Formatter: new(TextFormatter), 49 | Hooks: make(LevelHooks), 50 | Level: InfoLevel, 51 | } 52 | } 53 | 54 | // Adds a field to the log entry, note that you it doesn't log until you call 55 | // Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. 56 | // If you want multiple fields, use `WithFields`. 57 | func (logger *Logger) WithField(key string, value interface{}) *Entry { 58 | return NewEntry(logger).WithField(key, value) 59 | } 60 | 61 | // Adds a struct of fields to the log entry. All it does is call `WithField` for 62 | // each `Field`. 63 | func (logger *Logger) WithFields(fields Fields) *Entry { 64 | return NewEntry(logger).WithFields(fields) 65 | } 66 | 67 | // Add an error as single field to the log entry. All it does is call 68 | // `WithError` for the given `error`. 69 | func (logger *Logger) WithError(err error) *Entry { 70 | return NewEntry(logger).WithError(err) 71 | } 72 | 73 | func (logger *Logger) Debugf(format string, args ...interface{}) { 74 | if logger.Level >= DebugLevel { 75 | NewEntry(logger).Debugf(format, args...) 76 | } 77 | } 78 | 79 | func (logger *Logger) Infof(format string, args ...interface{}) { 80 | if logger.Level >= InfoLevel { 81 | NewEntry(logger).Infof(format, args...) 82 | } 83 | } 84 | 85 | func (logger *Logger) Printf(format string, args ...interface{}) { 86 | NewEntry(logger).Printf(format, args...) 87 | } 88 | 89 | func (logger *Logger) Warnf(format string, args ...interface{}) { 90 | if logger.Level >= WarnLevel { 91 | NewEntry(logger).Warnf(format, args...) 92 | } 93 | } 94 | 95 | func (logger *Logger) Warningf(format string, args ...interface{}) { 96 | if logger.Level >= WarnLevel { 97 | NewEntry(logger).Warnf(format, args...) 98 | } 99 | } 100 | 101 | func (logger *Logger) Errorf(format string, args ...interface{}) { 102 | if logger.Level >= ErrorLevel { 103 | NewEntry(logger).Errorf(format, args...) 104 | } 105 | } 106 | 107 | func (logger *Logger) Fatalf(format string, args ...interface{}) { 108 | if logger.Level >= FatalLevel { 109 | NewEntry(logger).Fatalf(format, args...) 110 | } 111 | os.Exit(1) 112 | } 113 | 114 | func (logger *Logger) Panicf(format string, args ...interface{}) { 115 | if logger.Level >= PanicLevel { 116 | NewEntry(logger).Panicf(format, args...) 117 | } 118 | } 119 | 120 | func (logger *Logger) Debug(args ...interface{}) { 121 | if logger.Level >= DebugLevel { 122 | NewEntry(logger).Debug(args...) 123 | } 124 | } 125 | 126 | func (logger *Logger) Info(args ...interface{}) { 127 | if logger.Level >= InfoLevel { 128 | NewEntry(logger).Info(args...) 129 | } 130 | } 131 | 132 | func (logger *Logger) Print(args ...interface{}) { 133 | NewEntry(logger).Info(args...) 134 | } 135 | 136 | func (logger *Logger) Warn(args ...interface{}) { 137 | if logger.Level >= WarnLevel { 138 | NewEntry(logger).Warn(args...) 139 | } 140 | } 141 | 142 | func (logger *Logger) Warning(args ...interface{}) { 143 | if logger.Level >= WarnLevel { 144 | NewEntry(logger).Warn(args...) 145 | } 146 | } 147 | 148 | func (logger *Logger) Error(args ...interface{}) { 149 | if logger.Level >= ErrorLevel { 150 | NewEntry(logger).Error(args...) 151 | } 152 | } 153 | 154 | func (logger *Logger) Fatal(args ...interface{}) { 155 | if logger.Level >= FatalLevel { 156 | NewEntry(logger).Fatal(args...) 157 | } 158 | os.Exit(1) 159 | } 160 | 161 | func (logger *Logger) Panic(args ...interface{}) { 162 | if logger.Level >= PanicLevel { 163 | NewEntry(logger).Panic(args...) 164 | } 165 | } 166 | 167 | func (logger *Logger) Debugln(args ...interface{}) { 168 | if logger.Level >= DebugLevel { 169 | NewEntry(logger).Debugln(args...) 170 | } 171 | } 172 | 173 | func (logger *Logger) Infoln(args ...interface{}) { 174 | if logger.Level >= InfoLevel { 175 | NewEntry(logger).Infoln(args...) 176 | } 177 | } 178 | 179 | func (logger *Logger) Println(args ...interface{}) { 180 | NewEntry(logger).Println(args...) 181 | } 182 | 183 | func (logger *Logger) Warnln(args ...interface{}) { 184 | if logger.Level >= WarnLevel { 185 | NewEntry(logger).Warnln(args...) 186 | } 187 | } 188 | 189 | func (logger *Logger) Warningln(args ...interface{}) { 190 | if logger.Level >= WarnLevel { 191 | NewEntry(logger).Warnln(args...) 192 | } 193 | } 194 | 195 | func (logger *Logger) Errorln(args ...interface{}) { 196 | if logger.Level >= ErrorLevel { 197 | NewEntry(logger).Errorln(args...) 198 | } 199 | } 200 | 201 | func (logger *Logger) Fatalln(args ...interface{}) { 202 | if logger.Level >= FatalLevel { 203 | NewEntry(logger).Fatalln(args...) 204 | } 205 | os.Exit(1) 206 | } 207 | 208 | func (logger *Logger) Panicln(args ...interface{}) { 209 | if logger.Level >= PanicLevel { 210 | NewEntry(logger).Panicln(args...) 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | ) 8 | 9 | // Fields type, used to pass to `WithFields`. 10 | type Fields map[string]interface{} 11 | 12 | // Level type 13 | type Level uint8 14 | 15 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 16 | func (level Level) String() string { 17 | switch level { 18 | case DebugLevel: 19 | return "debug" 20 | case InfoLevel: 21 | return "info" 22 | case WarnLevel: 23 | return "warning" 24 | case ErrorLevel: 25 | return "error" 26 | case FatalLevel: 27 | return "fatal" 28 | case PanicLevel: 29 | return "panic" 30 | } 31 | 32 | return "unknown" 33 | } 34 | 35 | // ParseLevel takes a string level and returns the Logrus log level constant. 36 | func ParseLevel(lvl string) (Level, error) { 37 | switch strings.ToLower(lvl) { 38 | case "panic": 39 | return PanicLevel, nil 40 | case "fatal": 41 | return FatalLevel, nil 42 | case "error": 43 | return ErrorLevel, nil 44 | case "warn", "warning": 45 | return WarnLevel, nil 46 | case "info": 47 | return InfoLevel, nil 48 | case "debug": 49 | return DebugLevel, nil 50 | } 51 | 52 | var l Level 53 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 54 | } 55 | 56 | // A constant exposing all logging levels 57 | var AllLevels = []Level{ 58 | PanicLevel, 59 | FatalLevel, 60 | ErrorLevel, 61 | WarnLevel, 62 | InfoLevel, 63 | DebugLevel, 64 | } 65 | 66 | // These are the different logging levels. You can set the logging level to log 67 | // on your instance of logger, obtained with `logrus.New()`. 68 | const ( 69 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 70 | // message passed to Debug, Info, ... 71 | PanicLevel Level = iota 72 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 73 | // logging level is set to Panic. 74 | FatalLevel 75 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 76 | // Commonly used for hooks to send errors to an error tracking service. 77 | ErrorLevel 78 | // WarnLevel level. Non-critical entries that deserve eyes. 79 | WarnLevel 80 | // InfoLevel level. General operational entries about what's going on inside the 81 | // application. 82 | InfoLevel 83 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 84 | DebugLevel 85 | ) 86 | 87 | // Won't compile if StdLogger can't be realized by a log.Logger 88 | var ( 89 | _ StdLogger = &log.Logger{} 90 | _ StdLogger = &Entry{} 91 | _ StdLogger = &Logger{} 92 | ) 93 | 94 | // StdLogger is what your logrus-enabled library should take, that way 95 | // it'll accept a stdlib logger and a logrus logger. There's no standard 96 | // interface, this is the closest we get, unfortunately. 97 | type StdLogger interface { 98 | Print(...interface{}) 99 | Printf(string, ...interface{}) 100 | Println(...interface{}) 101 | 102 | Fatal(...interface{}) 103 | Fatalf(string, ...interface{}) 104 | Fatalln(...interface{}) 105 | 106 | Panic(...interface{}) 107 | Panicf(string, ...interface{}) 108 | Panicln(...interface{}) 109 | } 110 | 111 | // The FieldLogger interface generalizes the Entry and Logger types 112 | type FieldLogger interface { 113 | WithField(key string, value interface{}) *Entry 114 | WithFields(fields Fields) *Entry 115 | WithError(err error) *Entry 116 | 117 | Debugf(format string, args ...interface{}) 118 | Infof(format string, args ...interface{}) 119 | Printf(format string, args ...interface{}) 120 | Warnf(format string, args ...interface{}) 121 | Warningf(format string, args ...interface{}) 122 | Errorf(format string, args ...interface{}) 123 | Fatalf(format string, args ...interface{}) 124 | Panicf(format string, args ...interface{}) 125 | 126 | Debug(args ...interface{}) 127 | Info(args ...interface{}) 128 | Print(args ...interface{}) 129 | Warn(args ...interface{}) 130 | Warning(args ...interface{}) 131 | Error(args ...interface{}) 132 | Fatal(args ...interface{}) 133 | Panic(args ...interface{}) 134 | 135 | Debugln(args ...interface{}) 136 | Infoln(args ...interface{}) 137 | Println(args ...interface{}) 138 | Warnln(args ...interface{}) 139 | Warningln(args ...interface{}) 140 | Errorln(args ...interface{}) 141 | Fatalln(args ...interface{}) 142 | Panicln(args ...interface{}) 143 | } 144 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/text_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "runtime" 7 | "sort" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | const ( 13 | nocolor = 0 14 | red = 31 15 | green = 32 16 | yellow = 33 17 | blue = 34 18 | gray = 37 19 | ) 20 | 21 | var ( 22 | baseTimestamp time.Time 23 | isTerminal bool 24 | ) 25 | 26 | func init() { 27 | baseTimestamp = time.Now() 28 | isTerminal = IsTerminal() 29 | } 30 | 31 | func miniTS() int { 32 | return int(time.Since(baseTimestamp) / time.Second) 33 | } 34 | 35 | type TextFormatter struct { 36 | // Set to true to bypass checking for a TTY before outputting colors. 37 | ForceColors bool 38 | 39 | // Force disabling colors. 40 | DisableColors bool 41 | 42 | // Disable timestamp logging. useful when output is redirected to logging 43 | // system that already adds timestamps. 44 | DisableTimestamp bool 45 | 46 | // Enable logging the full timestamp when a TTY is attached instead of just 47 | // the time passed since beginning of execution. 48 | FullTimestamp bool 49 | 50 | // TimestampFormat to use for display when a full timestamp is printed 51 | TimestampFormat string 52 | 53 | // The fields are sorted by default for a consistent output. For applications 54 | // that log extremely frequently and don't use the JSON formatter this may not 55 | // be desired. 56 | DisableSorting bool 57 | } 58 | 59 | func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { 60 | var keys []string = make([]string, 0, len(entry.Data)) 61 | for k := range entry.Data { 62 | keys = append(keys, k) 63 | } 64 | 65 | if !f.DisableSorting { 66 | sort.Strings(keys) 67 | } 68 | 69 | b := &bytes.Buffer{} 70 | 71 | prefixFieldClashes(entry.Data) 72 | 73 | isColorTerminal := isTerminal && (runtime.GOOS != "windows") 74 | isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors 75 | 76 | timestampFormat := f.TimestampFormat 77 | if timestampFormat == "" { 78 | timestampFormat = DefaultTimestampFormat 79 | } 80 | if isColored { 81 | f.printColored(b, entry, keys, timestampFormat) 82 | } else { 83 | if !f.DisableTimestamp { 84 | f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) 85 | } 86 | f.appendKeyValue(b, "level", entry.Level.String()) 87 | if entry.Message != "" { 88 | f.appendKeyValue(b, "msg", entry.Message) 89 | } 90 | for _, key := range keys { 91 | f.appendKeyValue(b, key, entry.Data[key]) 92 | } 93 | } 94 | 95 | b.WriteByte('\n') 96 | return b.Bytes(), nil 97 | } 98 | 99 | func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { 100 | var levelColor int 101 | switch entry.Level { 102 | case DebugLevel: 103 | levelColor = gray 104 | case WarnLevel: 105 | levelColor = yellow 106 | case ErrorLevel, FatalLevel, PanicLevel: 107 | levelColor = red 108 | default: 109 | levelColor = blue 110 | } 111 | 112 | levelText := strings.ToUpper(entry.Level.String())[0:4] 113 | 114 | if !f.FullTimestamp { 115 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) 116 | } else { 117 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) 118 | } 119 | for _, k := range keys { 120 | v := entry.Data[k] 121 | fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) 122 | } 123 | } 124 | 125 | func needsQuoting(text string) bool { 126 | for _, ch := range text { 127 | if !((ch >= 'a' && ch <= 'z') || 128 | (ch >= 'A' && ch <= 'Z') || 129 | (ch >= '0' && ch <= '9') || 130 | ch == '-' || ch == '.') { 131 | return false 132 | } 133 | } 134 | return true 135 | } 136 | 137 | func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { 138 | 139 | b.WriteString(key) 140 | b.WriteByte('=') 141 | 142 | switch value := value.(type) { 143 | case string: 144 | if needsQuoting(value) { 145 | b.WriteString(value) 146 | } else { 147 | fmt.Fprintf(b, "%q", value) 148 | } 149 | case error: 150 | errmsg := value.Error() 151 | if needsQuoting(errmsg) { 152 | b.WriteString(errmsg) 153 | } else { 154 | fmt.Fprintf(b, "%q", value) 155 | } 156 | default: 157 | fmt.Fprint(b, value) 158 | } 159 | 160 | b.WriteByte(' ') 161 | } 162 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/rancher/go-rancher-metadata/metadata/change.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | func (m *client) OnChange(intervalSeconds int, do func(string)) { 10 | interval := time.Duration(intervalSeconds) 11 | version := "init" 12 | 13 | for { 14 | newVersion, err := m.GetVersion() 15 | if err != nil { 16 | logrus.Errorf("Error reading metadata version: %v", err) 17 | time.Sleep(interval * time.Second) 18 | } else if version == newVersion { 19 | logrus.Debug("No changes in metadata version") 20 | time.Sleep(interval * time.Second) 21 | } else { 22 | logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) 23 | version = newVersion 24 | do(newVersion) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/rancher/go-rancher-metadata/metadata/metadata.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "net/http" 8 | ) 9 | 10 | type Client interface { 11 | OnChange(int, func(string)) 12 | SendRequest(string) ([]byte, error) 13 | GetVersion() (string, error) 14 | GetSelfHost() (Host, error) 15 | GetSelfContainer() (Container, error) 16 | GetSelfServiceByName(string) (Service, error) 17 | GetSelfService() (Service, error) 18 | GetSelfStack() (Stack, error) 19 | GetServices() ([]Service, error) 20 | GetStacks() ([]Stack, error) 21 | GetContainers() ([]Container, error) 22 | GetServiceContainers(string, string) ([]Container, error) 23 | GetHosts() ([]Host, error) 24 | GetHost(string) (Host, error) 25 | } 26 | 27 | type client struct { 28 | url string 29 | } 30 | 31 | func NewClient(url string) Client { 32 | return &client{url} 33 | } 34 | 35 | func NewClientAndWait(url string) (Client, error) { 36 | client := &client{url} 37 | 38 | if err := testConnection(client); err != nil { 39 | return nil, err 40 | } 41 | 42 | return client, nil 43 | } 44 | 45 | func (m *client) SendRequest(path string) ([]byte, error) { 46 | client := &http.Client{} 47 | req, err := http.NewRequest("GET", m.url+path, nil) 48 | req.Header.Add("Accept", "application/json") 49 | resp, err := client.Do(req) 50 | if err != nil { 51 | return nil, err 52 | } 53 | 54 | if resp.StatusCode != 200 { 55 | return nil, fmt.Errorf("Error %v accessing %v path", resp.StatusCode, path) 56 | } 57 | 58 | defer resp.Body.Close() 59 | body, err := ioutil.ReadAll(resp.Body) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return body, nil 64 | } 65 | 66 | func (m *client) GetVersion() (string, error) { 67 | resp, err := m.SendRequest("/version") 68 | if err != nil { 69 | return "", err 70 | } 71 | return string(resp[:]), nil 72 | } 73 | 74 | func (m *client) GetSelfHost() (Host, error) { 75 | resp, err := m.SendRequest("/self/host") 76 | var host Host 77 | if err != nil { 78 | return host, err 79 | } 80 | 81 | if err = json.Unmarshal(resp, &host); err != nil { 82 | return host, err 83 | } 84 | 85 | return host, nil 86 | } 87 | 88 | func (m *client) GetSelfContainer() (Container, error) { 89 | resp, err := m.SendRequest("/self/container") 90 | var container Container 91 | if err != nil { 92 | return container, err 93 | } 94 | 95 | if err = json.Unmarshal(resp, &container); err != nil { 96 | return container, err 97 | } 98 | 99 | return container, nil 100 | } 101 | 102 | func (m *client) GetSelfServiceByName(name string) (Service, error) { 103 | resp, err := m.SendRequest("/self/stack/services/" + name) 104 | var service Service 105 | if err != nil { 106 | return service, err 107 | } 108 | 109 | if err = json.Unmarshal(resp, &service); err != nil { 110 | return service, err 111 | } 112 | 113 | return service, nil 114 | } 115 | 116 | func (m *client) GetSelfService() (Service, error) { 117 | resp, err := m.SendRequest("/self/service") 118 | var service Service 119 | if err != nil { 120 | return service, err 121 | } 122 | 123 | if err = json.Unmarshal(resp, &service); err != nil { 124 | return service, err 125 | } 126 | 127 | return service, nil 128 | } 129 | 130 | func (m *client) GetSelfStack() (Stack, error) { 131 | resp, err := m.SendRequest("/self/stack") 132 | var stack Stack 133 | if err != nil { 134 | return stack, err 135 | } 136 | 137 | if err = json.Unmarshal(resp, &stack); err != nil { 138 | return stack, err 139 | } 140 | 141 | return stack, nil 142 | } 143 | 144 | func (m *client) GetServices() ([]Service, error) { 145 | resp, err := m.SendRequest("/services") 146 | var services []Service 147 | if err != nil { 148 | return services, err 149 | } 150 | 151 | if err = json.Unmarshal(resp, &services); err != nil { 152 | return services, err 153 | } 154 | return services, nil 155 | } 156 | 157 | func (m *client) GetStacks() ([]Stack, error) { 158 | resp, err := m.SendRequest("/stacks") 159 | var stacks []Stack 160 | if err != nil { 161 | return stacks, err 162 | } 163 | 164 | if err = json.Unmarshal(resp, &stacks); err != nil { 165 | return stacks, err 166 | } 167 | return stacks, nil 168 | } 169 | 170 | func (m *client) GetContainers() ([]Container, error) { 171 | resp, err := m.SendRequest("/containers") 172 | var containers []Container 173 | if err != nil { 174 | return containers, err 175 | } 176 | 177 | if err = json.Unmarshal(resp, &containers); err != nil { 178 | return containers, err 179 | } 180 | return containers, nil 181 | } 182 | 183 | func (m *client) GetServiceContainers(serviceName string, stackName string) ([]Container, error) { 184 | var serviceContainers = []Container{} 185 | containers, err := m.GetContainers() 186 | if err != nil { 187 | return serviceContainers, err 188 | } 189 | 190 | for _, container := range containers { 191 | if container.StackName == stackName && container.ServiceName == serviceName { 192 | serviceContainers = append(serviceContainers, container) 193 | } 194 | } 195 | 196 | return serviceContainers, nil 197 | } 198 | 199 | func (m *client) GetHosts() ([]Host, error) { 200 | resp, err := m.SendRequest("/hosts") 201 | var hosts []Host 202 | if err != nil { 203 | return hosts, err 204 | } 205 | 206 | if err = json.Unmarshal(resp, &hosts); err != nil { 207 | return hosts, err 208 | } 209 | return hosts, nil 210 | } 211 | 212 | func (m *client) GetHost(UUID string) (Host, error) { 213 | var host Host 214 | hosts, err := m.GetHosts() 215 | if err != nil { 216 | return host, err 217 | } 218 | for _, host := range hosts { 219 | if host.UUID == UUID { 220 | return host, nil 221 | } 222 | } 223 | 224 | return host, fmt.Errorf("could not find host by UUID %v", UUID) 225 | } 226 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/rancher/go-rancher-metadata/metadata/types.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | type Stack struct { 4 | EnvironmentName string `json:"environment_name"` 5 | EnvironmentUUID string `json:"environment_uuid"` 6 | Name string `json:"name"` 7 | Services []Service `json:"services"` 8 | } 9 | 10 | type HealthCheck struct { 11 | HealthyThreshold int `json:"healthy_threshold"` 12 | Interval int `json:"interval"` 13 | Port int `json:"port"` 14 | RequestLine string `json:"request_line"` 15 | ResponseTimeout int `json:"response_timeout"` 16 | UnhealthyThreshold int `json:"unhealthy_threshold"` 17 | } 18 | 19 | type Service struct { 20 | Scale int `json:"scale"` 21 | Name string `json:"name"` 22 | StackName string `json:"stack_name"` 23 | Kind string `json:"kind"` 24 | Hostname string `json:"hostname"` 25 | Vip string `json:"vip"` 26 | CreateIndex int `json:"create_index"` 27 | UUID string `json:"uuid"` 28 | ExternalIps []string `json:"external_ips"` 29 | Sidekicks []string `json:"sidekicks"` 30 | Containers []Container `json:"containers"` 31 | Ports []string `json:"ports"` 32 | Labels map[string]string `json:"labels"` 33 | Links map[string]string `json:"links"` 34 | Metadata map[string]interface{} `json:"metadata"` 35 | Token string `json:"token"` 36 | Fqdn string `json:"fqdn"` 37 | HealthCheck HealthCheck `json:"health_check"` 38 | } 39 | 40 | type Container struct { 41 | Name string `json:"name"` 42 | PrimaryIp string `json:"primary_ip"` 43 | Ips []string `json:"ips"` 44 | Ports []string `json:"ports"` 45 | ServiceName string `json:"service_name"` 46 | StackName string `json:"stack_name"` 47 | Labels map[string]string `json:"labels"` 48 | CreateIndex int `json:"create_index"` 49 | HostUUID string `json:"host_uuid"` 50 | UUID string `json:"uuid"` 51 | State string `json:"state"` 52 | HealthState string `json:"health_state"` 53 | ExternalId string `json:"external_id"` 54 | } 55 | 56 | type Host struct { 57 | Name string `json:"name"` 58 | AgentIP string `json:"agent_ip"` 59 | HostId int `json:"host_id"` 60 | Labels map[string]string `json:"labels"` 61 | UUID string `json:"uuid"` 62 | Hostname string `json:"hostname"` 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/rancher/go-rancher-metadata/metadata/utils.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func testConnection(mdClient Client) error { 8 | var err error 9 | maxTime := 20 * time.Second 10 | 11 | for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) { 12 | if _, err = mdClient.GetVersion(); err != nil { 13 | time.Sleep(i) 14 | } else { 15 | return nil 16 | } 17 | } 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_arm.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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 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 netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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 go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/mksysctl_openbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # Copyright 2011 The Go Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | # 8 | # Parse the header files for OpenBSD and generate a Go usable sysctl MIB. 9 | # 10 | # Build a MIB with each entry being an array containing the level, type and 11 | # a hash that will contain additional entries if the current entry is a node. 12 | # We then walk this MIB and create a flattened sysctl name to OID hash. 13 | # 14 | 15 | use strict; 16 | 17 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 18 | print STDERR "GOARCH or GOOS not defined in environment\n"; 19 | exit 1; 20 | } 21 | 22 | my $debug = 0; 23 | my %ctls = (); 24 | 25 | my @headers = qw ( 26 | sys/sysctl.h 27 | sys/socket.h 28 | sys/tty.h 29 | sys/malloc.h 30 | sys/mount.h 31 | sys/namei.h 32 | sys/sem.h 33 | sys/shm.h 34 | sys/vmmeter.h 35 | uvm/uvm_param.h 36 | uvm/uvm_swap_encrypt.h 37 | ddb/db_var.h 38 | net/if.h 39 | net/if_pfsync.h 40 | net/pipex.h 41 | netinet/in.h 42 | netinet/icmp_var.h 43 | netinet/igmp_var.h 44 | netinet/ip_ah.h 45 | netinet/ip_carp.h 46 | netinet/ip_divert.h 47 | netinet/ip_esp.h 48 | netinet/ip_ether.h 49 | netinet/ip_gre.h 50 | netinet/ip_ipcomp.h 51 | netinet/ip_ipip.h 52 | netinet/pim_var.h 53 | netinet/tcp_var.h 54 | netinet/udp_var.h 55 | netinet6/in6.h 56 | netinet6/ip6_divert.h 57 | netinet6/pim6_var.h 58 | netinet/icmp6.h 59 | netmpls/mpls.h 60 | ); 61 | 62 | my @ctls = qw ( 63 | kern 64 | vm 65 | fs 66 | net 67 | #debug # Special handling required 68 | hw 69 | #machdep # Arch specific 70 | user 71 | ddb 72 | #vfs # Special handling required 73 | fs.posix 74 | kern.forkstat 75 | kern.intrcnt 76 | kern.malloc 77 | kern.nchstats 78 | kern.seminfo 79 | kern.shminfo 80 | kern.timecounter 81 | kern.tty 82 | kern.watchdog 83 | net.bpf 84 | net.ifq 85 | net.inet 86 | net.inet.ah 87 | net.inet.carp 88 | net.inet.divert 89 | net.inet.esp 90 | net.inet.etherip 91 | net.inet.gre 92 | net.inet.icmp 93 | net.inet.igmp 94 | net.inet.ip 95 | net.inet.ip.ifq 96 | net.inet.ipcomp 97 | net.inet.ipip 98 | net.inet.mobileip 99 | net.inet.pfsync 100 | net.inet.pim 101 | net.inet.tcp 102 | net.inet.udp 103 | net.inet6 104 | net.inet6.divert 105 | net.inet6.ip6 106 | net.inet6.icmp6 107 | net.inet6.pim6 108 | net.inet6.tcp6 109 | net.inet6.udp6 110 | net.mpls 111 | net.mpls.ifq 112 | net.key 113 | net.pflow 114 | net.pfsync 115 | net.pipex 116 | net.rt 117 | vm.swapencrypt 118 | #vfsgenctl # Special handling required 119 | ); 120 | 121 | # Node name "fixups" 122 | my %ctl_map = ( 123 | "ipproto" => "net.inet", 124 | "net.inet.ipproto" => "net.inet", 125 | "net.inet6.ipv6proto" => "net.inet6", 126 | "net.inet6.ipv6" => "net.inet6.ip6", 127 | "net.inet.icmpv6" => "net.inet6.icmp6", 128 | "net.inet6.divert6" => "net.inet6.divert", 129 | "net.inet6.tcp6" => "net.inet.tcp", 130 | "net.inet6.udp6" => "net.inet.udp", 131 | "mpls" => "net.mpls", 132 | "swpenc" => "vm.swapencrypt" 133 | ); 134 | 135 | # Node mappings 136 | my %node_map = ( 137 | "net.inet.ip.ifq" => "net.ifq", 138 | "net.inet.pfsync" => "net.pfsync", 139 | "net.mpls.ifq" => "net.ifq" 140 | ); 141 | 142 | my $ctlname; 143 | my %mib = (); 144 | my %sysctl = (); 145 | my $node; 146 | 147 | sub debug() { 148 | print STDERR "$_[0]\n" if $debug; 149 | } 150 | 151 | # Walk the MIB and build a sysctl name to OID mapping. 152 | sub build_sysctl() { 153 | my ($node, $name, $oid) = @_; 154 | my %node = %{$node}; 155 | my @oid = @{$oid}; 156 | 157 | foreach my $key (sort keys %node) { 158 | my @node = @{$node{$key}}; 159 | my $nodename = $name.($name ne '' ? '.' : '').$key; 160 | my @nodeoid = (@oid, $node[0]); 161 | if ($node[1] eq 'CTLTYPE_NODE') { 162 | if (exists $node_map{$nodename}) { 163 | $node = \%mib; 164 | $ctlname = $node_map{$nodename}; 165 | foreach my $part (split /\./, $ctlname) { 166 | $node = \%{@{$$node{$part}}[2]}; 167 | } 168 | } else { 169 | $node = $node[2]; 170 | } 171 | &build_sysctl($node, $nodename, \@nodeoid); 172 | } elsif ($node[1] ne '') { 173 | $sysctl{$nodename} = \@nodeoid; 174 | } 175 | } 176 | } 177 | 178 | foreach my $ctl (@ctls) { 179 | $ctls{$ctl} = $ctl; 180 | } 181 | 182 | # Build MIB 183 | foreach my $header (@headers) { 184 | &debug("Processing $header..."); 185 | open HEADER, "/usr/include/$header" || 186 | print STDERR "Failed to open $header\n"; 187 | while (
) { 188 | if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ || 189 | $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ || 190 | $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) { 191 | if ($1 eq 'CTL_NAMES') { 192 | # Top level. 193 | $node = \%mib; 194 | } else { 195 | # Node. 196 | my $nodename = lc($2); 197 | if ($header =~ /^netinet\//) { 198 | $ctlname = "net.inet.$nodename"; 199 | } elsif ($header =~ /^netinet6\//) { 200 | $ctlname = "net.inet6.$nodename"; 201 | } elsif ($header =~ /^net\//) { 202 | $ctlname = "net.$nodename"; 203 | } else { 204 | $ctlname = "$nodename"; 205 | $ctlname =~ s/^(fs|net|kern)_/$1\./; 206 | } 207 | if (exists $ctl_map{$ctlname}) { 208 | $ctlname = $ctl_map{$ctlname}; 209 | } 210 | if (not exists $ctls{$ctlname}) { 211 | &debug("Ignoring $ctlname..."); 212 | next; 213 | } 214 | 215 | # Walk down from the top of the MIB. 216 | $node = \%mib; 217 | foreach my $part (split /\./, $ctlname) { 218 | if (not exists $$node{$part}) { 219 | &debug("Missing node $part"); 220 | $$node{$part} = [ 0, '', {} ]; 221 | } 222 | $node = \%{@{$$node{$part}}[2]}; 223 | } 224 | } 225 | 226 | # Populate current node with entries. 227 | my $i = -1; 228 | while (defined($_) && $_ !~ /^}/) { 229 | $_ =
; 230 | $i++ if $_ =~ /{.*}/; 231 | next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/; 232 | $$node{$1} = [ $i, $2, {} ]; 233 | } 234 | } 235 | } 236 | close HEADER; 237 | } 238 | 239 | &build_sysctl(\%mib, "", []); 240 | 241 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,linux 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 13 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 14 | //sys Fchown(fd int, uid int, gid int) (err error) 15 | //sys Fstat(fd int, stat *Stat_t) (err error) 16 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 17 | //sys Ftruncate(fd int, length int64) (err error) 18 | //sysnb Getegid() (egid int) 19 | //sysnb Geteuid() (euid int) 20 | //sysnb Getgid() (gid int) 21 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 22 | //sysnb Getuid() (uid int) 23 | //sysnb InotifyInit() (fd int, err error) 24 | //sys Ioperm(from int, num int, on int) (err error) 25 | //sys Iopl(level int) (err error) 26 | //sys Lchown(path string, uid int, gid int) (err error) 27 | //sys Listen(s int, n int) (err error) 28 | //sys Lstat(path string, stat *Stat_t) (err error) 29 | //sys Pause() (err error) 30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 31 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 32 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 33 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 34 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 35 | //sys Setfsgid(gid int) (err error) 36 | //sys Setfsuid(uid int) (err error) 37 | //sysnb Setregid(rgid int, egid int) (err error) 38 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 39 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 40 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 41 | //sysnb Setreuid(ruid int, euid int) (err error) 42 | //sys Shutdown(fd int, how int) (err error) 43 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 44 | //sys Stat(path string, stat *Stat_t) (err error) 45 | //sys Statfs(path string, buf *Statfs_t) (err error) 46 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 47 | //sys Truncate(path string, length int64) (err error) 48 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 49 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 50 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 52 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 53 | //sysnb setgroups(n int, list *_Gid_t) (err error) 54 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 55 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 56 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 57 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 58 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 60 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 61 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 62 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 64 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 65 | 66 | //go:noescape 67 | func gettimeofday(tv *Timeval) (err syscall.Errno) 68 | 69 | func Gettimeofday(tv *Timeval) (err error) { 70 | errno := gettimeofday(tv) 71 | if errno != 0 { 72 | return errno 73 | } 74 | return nil 75 | } 76 | 77 | func Getpagesize() int { return 4096 } 78 | 79 | func Time(t *Time_t) (tt Time_t, err error) { 80 | var tv Timeval 81 | errno := gettimeofday(&tv) 82 | if errno != 0 { 83 | return 0, errno 84 | } 85 | if t != nil { 86 | *t = Time_t(tv.Sec) 87 | } 88 | return Time_t(tv.Sec), nil 89 | } 90 | 91 | //sys Utime(path string, buf *Utimbuf) (err error) 92 | 93 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 94 | 95 | func NsecToTimespec(nsec int64) (ts Timespec) { 96 | ts.Sec = nsec / 1e9 97 | ts.Nsec = nsec % 1e9 98 | return 99 | } 100 | 101 | func NsecToTimeval(nsec int64) (tv Timeval) { 102 | nsec += 999 // round up to microsecond 103 | tv.Sec = nsec / 1e9 104 | tv.Usec = nsec % 1e9 / 1e3 105 | return 106 | } 107 | 108 | //sysnb pipe(p *[2]_C_int) (err error) 109 | 110 | func Pipe(p []int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe(&pp) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 122 | 123 | func Pipe2(p []int, flags int) (err error) { 124 | if len(p) != 2 { 125 | return EINVAL 126 | } 127 | var pp [2]_C_int 128 | err = pipe2(&pp, flags) 129 | p[0] = int(pp[0]) 130 | p[1] = int(pp[1]) 131 | return 132 | } 133 | 134 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 135 | 136 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 137 | 138 | func (iov *Iovec) SetLen(length int) { 139 | iov.Len = uint64(length) 140 | } 141 | 142 | func (msghdr *Msghdr) SetControllen(length int) { 143 | msghdr.Controllen = uint64(length) 144 | } 145 | 146 | func (cmsg *Cmsghdr) SetLen(length int) { 147 | cmsg.Len = uint64(length) 148 | } 149 | 150 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 151 | 152 | func Poll(fds []PollFd, timeout int) (n int, err error) { 153 | if len(fds) == 0 { 154 | return poll(nil, 0, timeout) 155 | } 156 | return poll(&fds[0], len(fds), timeout) 157 | } 158 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 arm64,linux 6 | 7 | package unix 8 | 9 | const _SYS_dup = SYS_DUP3 10 | 11 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 21 | //sysnb Getuid() (uid int) 22 | //sys Listen(s int, n int) (err error) 23 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 24 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 25 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 26 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 27 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 28 | //sys Setfsgid(gid int) (err error) 29 | //sys Setfsuid(uid int) (err error) 30 | //sysnb Setregid(rgid int, egid int) (err error) 31 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 32 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 33 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 34 | //sysnb Setreuid(ruid int, euid int) (err error) 35 | //sys Shutdown(fd int, how int) (err error) 36 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 37 | 38 | func Stat(path string, stat *Stat_t) (err error) { 39 | return Fstatat(AT_FDCWD, path, stat, 0) 40 | } 41 | 42 | func Lchown(path string, uid int, gid int) (err error) { 43 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 44 | } 45 | 46 | func Lstat(path string, stat *Stat_t) (err error) { 47 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 48 | } 49 | 50 | //sys Statfs(path string, buf *Statfs_t) (err error) 51 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 52 | //sys Truncate(path string, length int64) (err error) 53 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 54 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 55 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 56 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 57 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 58 | //sysnb setgroups(n int, list *_Gid_t) (err error) 59 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 60 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 61 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 62 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 63 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 64 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 65 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 66 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 67 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 68 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 69 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 70 | 71 | func Getpagesize() int { return 65536 } 72 | 73 | //sysnb Gettimeofday(tv *Timeval) (err error) 74 | 75 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 76 | 77 | func NsecToTimespec(nsec int64) (ts Timespec) { 78 | ts.Sec = nsec / 1e9 79 | ts.Nsec = nsec % 1e9 80 | return 81 | } 82 | 83 | func NsecToTimeval(nsec int64) (tv Timeval) { 84 | nsec += 999 // round up to microsecond 85 | tv.Sec = nsec / 1e9 86 | tv.Usec = nsec % 1e9 / 1e3 87 | return 88 | } 89 | 90 | func Time(t *Time_t) (Time_t, error) { 91 | var tv Timeval 92 | err := Gettimeofday(&tv) 93 | if err != nil { 94 | return 0, err 95 | } 96 | if t != nil { 97 | *t = Time_t(tv.Sec) 98 | } 99 | return Time_t(tv.Sec), nil 100 | } 101 | 102 | func Utime(path string, buf *Utimbuf) error { 103 | tv := []Timeval{ 104 | {Sec: buf.Actime}, 105 | {Sec: buf.Modtime}, 106 | } 107 | return Utimes(path, tv) 108 | } 109 | 110 | func Pipe(p []int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe2(&pp, 0) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 122 | 123 | func Pipe2(p []int, flags int) (err error) { 124 | if len(p) != 2 { 125 | return EINVAL 126 | } 127 | var pp [2]_C_int 128 | err = pipe2(&pp, flags) 129 | p[0] = int(pp[0]) 130 | p[1] = int(pp[1]) 131 | return 132 | } 133 | 134 | func (r *PtraceRegs) PC() uint64 { return r.Pc } 135 | 136 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } 137 | 138 | func (iov *Iovec) SetLen(length int) { 139 | iov.Len = uint64(length) 140 | } 141 | 142 | func (msghdr *Msghdr) SetControllen(length int) { 143 | msghdr.Controllen = uint64(length) 144 | } 145 | 146 | func (cmsg *Cmsghdr) SetLen(length int) { 147 | cmsg.Len = uint64(length) 148 | } 149 | 150 | func InotifyInit() (fd int, err error) { 151 | return InotifyInit1(0) 152 | } 153 | 154 | func Dup2(oldfd int, newfd int) (err error) { 155 | return Dup3(oldfd, newfd, 0) 156 | } 157 | 158 | func Pause() (err error) { 159 | _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) 160 | if e1 != 0 { 161 | err = errnoErr(e1) 162 | } 163 | return 164 | } 165 | 166 | // TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove 167 | // these when the deprecated syscalls that the syscall package relies on 168 | // are removed. 169 | const ( 170 | SYS_GETPGRP = 1060 171 | SYS_UTIMES = 1037 172 | SYS_FUTIMESAT = 1066 173 | SYS_PAUSE = 1061 174 | SYS_USTAT = 1070 175 | SYS_UTIME = 1063 176 | SYS_LCHOWN = 1032 177 | SYS_TIME = 1062 178 | SYS_EPOLL_CREATE = 1042 179 | SYS_EPOLL_WAIT = 1069 180 | ) 181 | 182 | func Poll(fds []PollFd, timeout int) (n int, err error) { 183 | var ts *Timespec 184 | if timeout >= 0 { 185 | ts = new(Timespec) 186 | *ts = NsecToTimespec(int64(timeout) * 1e6) 187 | } 188 | if len(fds) == 0 { 189 | return ppoll(nil, 0, ts, nil) 190 | } 191 | return ppoll(&fds[0], len(fds), ts, nil) 192 | } 193 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Ioperm(from int, num int, on int) (err error) 23 | //sys Iopl(level int) (err error) 24 | //sys Lchown(path string, uid int, gid int) (err error) 25 | //sys Listen(s int, n int) (err error) 26 | //sys Lstat(path string, stat *Stat_t) (err error) 27 | //sys Pause() (err error) 28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Getpagesize() int { return 65536 } 65 | 66 | //sysnb Gettimeofday(tv *Timeval) (err error) 67 | //sysnb Time(t *Time_t) (tt Time_t, err error) 68 | 69 | //sys Utime(path string, buf *Utimbuf) (err error) 70 | 71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 72 | 73 | func NsecToTimespec(nsec int64) (ts Timespec) { 74 | ts.Sec = nsec / 1e9 75 | ts.Nsec = nsec % 1e9 76 | return 77 | } 78 | 79 | func NsecToTimeval(nsec int64) (tv Timeval) { 80 | nsec += 999 // round up to microsecond 81 | tv.Sec = nsec / 1e9 82 | tv.Usec = nsec % 1e9 / 1e3 83 | return 84 | } 85 | 86 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 87 | 88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 89 | 90 | func (iov *Iovec) SetLen(length int) { 91 | iov.Len = uint64(length) 92 | } 93 | 94 | func (msghdr *Msghdr) SetControllen(length int) { 95 | msghdr.Controllen = uint64(length) 96 | } 97 | 98 | func (cmsg *Cmsghdr) SetLen(length int) { 99 | cmsg.Len = uint64(length) 100 | } 101 | 102 | //sysnb pipe(p *[2]_C_int) (err error) 103 | 104 | func Pipe(p []int) (err error) { 105 | if len(p) != 2 { 106 | return EINVAL 107 | } 108 | var pp [2]_C_int 109 | err = pipe(&pp) 110 | p[0] = int(pp[0]) 111 | p[1] = int(pp[1]) 112 | return 113 | } 114 | 115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 116 | 117 | func Pipe2(p []int, flags int) (err error) { 118 | if len(p) != 2 { 119 | return EINVAL 120 | } 121 | var pp [2]_C_int 122 | err = pipe2(&pp, flags) 123 | p[0] = int(pp[0]) 124 | p[1] = int(pp[1]) 125 | return 126 | } 127 | 128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 129 | 130 | func Poll(fds []PollFd, timeout int) (n int, err error) { 131 | if len(fds) == 0 { 132 | return poll(nil, 0, timeout) 133 | } 134 | return poll(&fds[0], len(fds), timeout) 135 | } 136 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.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 arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_no_getwd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define __DARWIN_UNIX03 0 18 | #define KERNEL 19 | #define _DARWIN_USE_64_BIT_INODE 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | enum { 52 | sizeofPtr = sizeof(void*), 53 | }; 54 | 55 | union sockaddr_all { 56 | struct sockaddr s1; // this one gets used for fields 57 | struct sockaddr_in s2; // these pad it out 58 | struct sockaddr_in6 s3; 59 | struct sockaddr_un s4; 60 | struct sockaddr_dl s5; 61 | }; 62 | 63 | struct sockaddr_any { 64 | struct sockaddr addr; 65 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 66 | }; 67 | 68 | */ 69 | import "C" 70 | 71 | // Machine characteristics; for internal use. 72 | 73 | const ( 74 | sizeofPtr = C.sizeofPtr 75 | sizeofShort = C.sizeof_short 76 | sizeofInt = C.sizeof_int 77 | sizeofLong = C.sizeof_long 78 | sizeofLongLong = C.sizeof_longlong 79 | ) 80 | 81 | // Basic types 82 | 83 | type ( 84 | _C_short C.short 85 | _C_int C.int 86 | _C_long C.long 87 | _C_long_long C.longlong 88 | ) 89 | 90 | // Time 91 | 92 | type Timespec C.struct_timespec 93 | 94 | type Timeval C.struct_timeval 95 | 96 | type Timeval32 C.struct_timeval32 97 | 98 | // Processes 99 | 100 | type Rusage C.struct_rusage 101 | 102 | type Rlimit C.struct_rlimit 103 | 104 | type _Gid_t C.gid_t 105 | 106 | // Files 107 | 108 | type Stat_t C.struct_stat64 109 | 110 | type Statfs_t C.struct_statfs64 111 | 112 | type Flock_t C.struct_flock 113 | 114 | type Fstore_t C.struct_fstore 115 | 116 | type Radvisory_t C.struct_radvisory 117 | 118 | type Fbootstraptransfer_t C.struct_fbootstraptransfer 119 | 120 | type Log2phys_t C.struct_log2phys 121 | 122 | type Fsid C.struct_fsid 123 | 124 | type Dirent C.struct_dirent 125 | 126 | // Sockets 127 | 128 | type RawSockaddrInet4 C.struct_sockaddr_in 129 | 130 | type RawSockaddrInet6 C.struct_sockaddr_in6 131 | 132 | type RawSockaddrUnix C.struct_sockaddr_un 133 | 134 | type RawSockaddrDatalink C.struct_sockaddr_dl 135 | 136 | type RawSockaddr C.struct_sockaddr 137 | 138 | type RawSockaddrAny C.struct_sockaddr_any 139 | 140 | type _Socklen C.socklen_t 141 | 142 | type Linger C.struct_linger 143 | 144 | type Iovec C.struct_iovec 145 | 146 | type IPMreq C.struct_ip_mreq 147 | 148 | type IPv6Mreq C.struct_ipv6_mreq 149 | 150 | type Msghdr C.struct_msghdr 151 | 152 | type Cmsghdr C.struct_cmsghdr 153 | 154 | type Inet4Pktinfo C.struct_in_pktinfo 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 202 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 203 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 204 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 205 | ) 206 | 207 | type IfMsghdr C.struct_if_msghdr 208 | 209 | type IfData C.struct_if_data 210 | 211 | type IfaMsghdr C.struct_ifa_msghdr 212 | 213 | type IfmaMsghdr C.struct_ifma_msghdr 214 | 215 | type IfmaMsghdr2 C.struct_ifma_msghdr2 216 | 217 | type RtMsghdr C.struct_rt_msghdr 218 | 219 | type RtMetrics C.struct_rt_metrics 220 | 221 | // Berkeley packet filter 222 | 223 | const ( 224 | SizeofBpfVersion = C.sizeof_struct_bpf_version 225 | SizeofBpfStat = C.sizeof_struct_bpf_stat 226 | SizeofBpfProgram = C.sizeof_struct_bpf_program 227 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 228 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 229 | ) 230 | 231 | type BpfVersion C.struct_bpf_version 232 | 233 | type BpfStat C.struct_bpf_stat 234 | 235 | type BpfProgram C.struct_bpf_program 236 | 237 | type BpfInsn C.struct_bpf_insn 238 | 239 | type BpfHdr C.struct_bpf_hdr 240 | 241 | // Terminal handling 242 | 243 | type Termios C.struct_termios 244 | 245 | // fchmodat-like syscalls. 246 | 247 | const ( 248 | AT_FDCWD = C.AT_FDCWD 249 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 250 | ) 251 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | enum { 47 | sizeofPtr = sizeof(void*), 48 | }; 49 | 50 | union sockaddr_all { 51 | struct sockaddr s1; // this one gets used for fields 52 | struct sockaddr_in s2; // these pad it out 53 | struct sockaddr_in6 s3; 54 | struct sockaddr_un s4; 55 | struct sockaddr_dl s5; 56 | }; 57 | 58 | struct sockaddr_any { 59 | struct sockaddr addr; 60 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 61 | }; 62 | 63 | */ 64 | import "C" 65 | 66 | // Machine characteristics; for internal use. 67 | 68 | const ( 69 | sizeofPtr = C.sizeofPtr 70 | sizeofShort = C.sizeof_short 71 | sizeofInt = C.sizeof_int 72 | sizeofLong = C.sizeof_long 73 | sizeofLongLong = C.sizeof_longlong 74 | ) 75 | 76 | // Basic types 77 | 78 | type ( 79 | _C_short C.short 80 | _C_int C.int 81 | _C_long C.long 82 | _C_long_long C.longlong 83 | ) 84 | 85 | // Time 86 | 87 | type Timespec C.struct_timespec 88 | 89 | type Timeval C.struct_timeval 90 | 91 | // Processes 92 | 93 | type Rusage C.struct_rusage 94 | 95 | type Rlimit C.struct_rlimit 96 | 97 | type _Gid_t C.gid_t 98 | 99 | // Files 100 | 101 | const ( // Directory mode bits 102 | S_IFMT = C.S_IFMT 103 | S_IFIFO = C.S_IFIFO 104 | S_IFCHR = C.S_IFCHR 105 | S_IFDIR = C.S_IFDIR 106 | S_IFBLK = C.S_IFBLK 107 | S_IFREG = C.S_IFREG 108 | S_IFLNK = C.S_IFLNK 109 | S_IFSOCK = C.S_IFSOCK 110 | S_ISUID = C.S_ISUID 111 | S_ISGID = C.S_ISGID 112 | S_ISVTX = C.S_ISVTX 113 | S_IRUSR = C.S_IRUSR 114 | S_IWUSR = C.S_IWUSR 115 | S_IXUSR = C.S_IXUSR 116 | ) 117 | 118 | type Stat_t C.struct_stat 119 | 120 | type Statfs_t C.struct_statfs 121 | 122 | type Flock_t C.struct_flock 123 | 124 | type Dirent C.struct_dirent 125 | 126 | type Fsid C.struct_fsid 127 | 128 | // Sockets 129 | 130 | type RawSockaddrInet4 C.struct_sockaddr_in 131 | 132 | type RawSockaddrInet6 C.struct_sockaddr_in6 133 | 134 | type RawSockaddrUnix C.struct_sockaddr_un 135 | 136 | type RawSockaddrDatalink C.struct_sockaddr_dl 137 | 138 | type RawSockaddr C.struct_sockaddr 139 | 140 | type RawSockaddrAny C.struct_sockaddr_any 141 | 142 | type _Socklen C.socklen_t 143 | 144 | type Linger C.struct_linger 145 | 146 | type Iovec C.struct_iovec 147 | 148 | type IPMreq C.struct_ip_mreq 149 | 150 | type IPv6Mreq C.struct_ipv6_mreq 151 | 152 | type Msghdr C.struct_msghdr 153 | 154 | type Cmsghdr C.struct_cmsghdr 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 174 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 175 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 176 | ) 177 | 178 | // Ptrace requests 179 | 180 | const ( 181 | PTRACE_TRACEME = C.PT_TRACE_ME 182 | PTRACE_CONT = C.PT_CONTINUE 183 | PTRACE_KILL = C.PT_KILL 184 | ) 185 | 186 | // Events (kqueue, kevent) 187 | 188 | type Kevent_t C.struct_kevent 189 | 190 | // Select 191 | 192 | type FdSet C.fd_set 193 | 194 | // Routing and interface messages 195 | 196 | const ( 197 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 198 | SizeofIfData = C.sizeof_struct_if_data 199 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 200 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfmaMsghdr C.struct_ifma_msghdr 213 | 214 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 215 | 216 | type RtMsghdr C.struct_rt_msghdr 217 | 218 | type RtMetrics C.struct_rt_metrics 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | // Terminal handling 241 | 242 | type Termios C.struct_termios 243 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/types_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | enum { 49 | sizeofPtr = sizeof(void*), 50 | }; 51 | 52 | union sockaddr_all { 53 | struct sockaddr s1; // this one gets used for fields 54 | struct sockaddr_in s2; // these pad it out 55 | struct sockaddr_in6 s3; 56 | struct sockaddr_un s4; 57 | struct sockaddr_dl s5; 58 | }; 59 | 60 | struct sockaddr_any { 61 | struct sockaddr addr; 62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63 | }; 64 | 65 | */ 66 | import "C" 67 | 68 | // Machine characteristics; for internal use. 69 | 70 | const ( 71 | sizeofPtr = C.sizeofPtr 72 | sizeofShort = C.sizeof_short 73 | sizeofInt = C.sizeof_int 74 | sizeofLong = C.sizeof_long 75 | sizeofLongLong = C.sizeof_longlong 76 | ) 77 | 78 | // Basic types 79 | 80 | type ( 81 | _C_short C.short 82 | _C_int C.int 83 | _C_long C.long 84 | _C_long_long C.longlong 85 | ) 86 | 87 | // Time 88 | 89 | type Timespec C.struct_timespec 90 | 91 | type Timeval C.struct_timeval 92 | 93 | // Processes 94 | 95 | type Rusage C.struct_rusage 96 | 97 | type Rlimit C.struct_rlimit 98 | 99 | type _Gid_t C.gid_t 100 | 101 | // Files 102 | 103 | type Stat_t C.struct_stat 104 | 105 | type Statfs_t C.struct_statfs 106 | 107 | type Flock_t C.struct_flock 108 | 109 | type Dirent C.struct_dirent 110 | 111 | type Fsid C.fsid_t 112 | 113 | // Sockets 114 | 115 | type RawSockaddrInet4 C.struct_sockaddr_in 116 | 117 | type RawSockaddrInet6 C.struct_sockaddr_in6 118 | 119 | type RawSockaddrUnix C.struct_sockaddr_un 120 | 121 | type RawSockaddrDatalink C.struct_sockaddr_dl 122 | 123 | type RawSockaddr C.struct_sockaddr 124 | 125 | type RawSockaddrAny C.struct_sockaddr_any 126 | 127 | type _Socklen C.socklen_t 128 | 129 | type Linger C.struct_linger 130 | 131 | type Iovec C.struct_iovec 132 | 133 | type IPMreq C.struct_ip_mreq 134 | 135 | type IPv6Mreq C.struct_ipv6_mreq 136 | 137 | type Msghdr C.struct_msghdr 138 | 139 | type Cmsghdr C.struct_cmsghdr 140 | 141 | type Inet6Pktinfo C.struct_in6_pktinfo 142 | 143 | type IPv6MTUInfo C.struct_ip6_mtuinfo 144 | 145 | type ICMPv6Filter C.struct_icmp6_filter 146 | 147 | const ( 148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 153 | SizeofLinger = C.sizeof_struct_linger 154 | SizeofIPMreq = C.sizeof_struct_ip_mreq 155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 156 | SizeofMsghdr = C.sizeof_struct_msghdr 157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 161 | ) 162 | 163 | // Ptrace requests 164 | 165 | const ( 166 | PTRACE_TRACEME = C.PT_TRACE_ME 167 | PTRACE_CONT = C.PT_CONTINUE 168 | PTRACE_KILL = C.PT_KILL 169 | ) 170 | 171 | // Events (kqueue, kevent) 172 | 173 | type Kevent_t C.struct_kevent 174 | 175 | // Select 176 | 177 | type FdSet C.fd_set 178 | 179 | // Routing and interface messages 180 | 181 | const ( 182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 183 | SizeofIfData = C.sizeof_struct_if_data 184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 188 | ) 189 | 190 | type IfMsghdr C.struct_if_msghdr 191 | 192 | type IfData C.struct_if_data 193 | 194 | type IfaMsghdr C.struct_ifa_msghdr 195 | 196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 197 | 198 | type RtMsghdr C.struct_rt_msghdr 199 | 200 | type RtMetrics C.struct_rt_metrics 201 | 202 | type Mclpool C.struct_mclpool 203 | 204 | // Berkeley packet filter 205 | 206 | const ( 207 | SizeofBpfVersion = C.sizeof_struct_bpf_version 208 | SizeofBpfStat = C.sizeof_struct_bpf_stat 209 | SizeofBpfProgram = C.sizeof_struct_bpf_program 210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 212 | ) 213 | 214 | type BpfVersion C.struct_bpf_version 215 | 216 | type BpfStat C.struct_bpf_stat 217 | 218 | type BpfProgram C.struct_bpf_program 219 | 220 | type BpfInsn C.struct_bpf_insn 221 | 222 | type BpfHdr C.struct_bpf_hdr 223 | 224 | type BpfTimeval C.struct_bpf_timeval 225 | 226 | // Terminal handling 227 | 228 | type Termios C.struct_termios 229 | 230 | // Sysctl 231 | 232 | type Sysctlnode C.struct_sysctlnode 233 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/types_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | enum { 48 | sizeofPtr = sizeof(void*), 49 | }; 50 | 51 | union sockaddr_all { 52 | struct sockaddr s1; // this one gets used for fields 53 | struct sockaddr_in s2; // these pad it out 54 | struct sockaddr_in6 s3; 55 | struct sockaddr_un s4; 56 | struct sockaddr_dl s5; 57 | }; 58 | 59 | struct sockaddr_any { 60 | struct sockaddr addr; 61 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 62 | }; 63 | 64 | */ 65 | import "C" 66 | 67 | // Machine characteristics; for internal use. 68 | 69 | const ( 70 | sizeofPtr = C.sizeofPtr 71 | sizeofShort = C.sizeof_short 72 | sizeofInt = C.sizeof_int 73 | sizeofLong = C.sizeof_long 74 | sizeofLongLong = C.sizeof_longlong 75 | ) 76 | 77 | // Basic types 78 | 79 | type ( 80 | _C_short C.short 81 | _C_int C.int 82 | _C_long C.long 83 | _C_long_long C.longlong 84 | ) 85 | 86 | // Time 87 | 88 | type Timespec C.struct_timespec 89 | 90 | type Timeval C.struct_timeval 91 | 92 | // Processes 93 | 94 | type Rusage C.struct_rusage 95 | 96 | type Rlimit C.struct_rlimit 97 | 98 | type _Gid_t C.gid_t 99 | 100 | // Files 101 | 102 | const ( // Directory mode bits 103 | S_IFMT = C.S_IFMT 104 | S_IFIFO = C.S_IFIFO 105 | S_IFCHR = C.S_IFCHR 106 | S_IFDIR = C.S_IFDIR 107 | S_IFBLK = C.S_IFBLK 108 | S_IFREG = C.S_IFREG 109 | S_IFLNK = C.S_IFLNK 110 | S_IFSOCK = C.S_IFSOCK 111 | S_ISUID = C.S_ISUID 112 | S_ISGID = C.S_ISGID 113 | S_ISVTX = C.S_ISVTX 114 | S_IRUSR = C.S_IRUSR 115 | S_IWUSR = C.S_IWUSR 116 | S_IXUSR = C.S_IXUSR 117 | ) 118 | 119 | type Stat_t C.struct_stat 120 | 121 | type Statfs_t C.struct_statfs 122 | 123 | type Flock_t C.struct_flock 124 | 125 | type Dirent C.struct_dirent 126 | 127 | type Fsid C.fsid_t 128 | 129 | // Sockets 130 | 131 | type RawSockaddrInet4 C.struct_sockaddr_in 132 | 133 | type RawSockaddrInet6 C.struct_sockaddr_in6 134 | 135 | type RawSockaddrUnix C.struct_sockaddr_un 136 | 137 | type RawSockaddrDatalink C.struct_sockaddr_dl 138 | 139 | type RawSockaddr C.struct_sockaddr 140 | 141 | type RawSockaddrAny C.struct_sockaddr_any 142 | 143 | type _Socklen C.socklen_t 144 | 145 | type Linger C.struct_linger 146 | 147 | type Iovec C.struct_iovec 148 | 149 | type IPMreq C.struct_ip_mreq 150 | 151 | type IPv6Mreq C.struct_ipv6_mreq 152 | 153 | type Msghdr C.struct_msghdr 154 | 155 | type Cmsghdr C.struct_cmsghdr 156 | 157 | type Inet6Pktinfo C.struct_in6_pktinfo 158 | 159 | type IPv6MTUInfo C.struct_ip6_mtuinfo 160 | 161 | type ICMPv6Filter C.struct_icmp6_filter 162 | 163 | const ( 164 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 165 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 166 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 167 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 168 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 169 | SizeofLinger = C.sizeof_struct_linger 170 | SizeofIPMreq = C.sizeof_struct_ip_mreq 171 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 172 | SizeofMsghdr = C.sizeof_struct_msghdr 173 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 213 | 214 | type RtMsghdr C.struct_rt_msghdr 215 | 216 | type RtMetrics C.struct_rt_metrics 217 | 218 | type Mclpool C.struct_mclpool 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | type BpfTimeval C.struct_bpf_timeval 241 | 242 | // Terminal handling 243 | 244 | type Termios C.struct_termios 245 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | // These defines ensure that builds done on newer versions of Solaris are 19 | // backwards-compatible with older versions of Solaris and 20 | // OpenSolaris-based derivatives. 21 | #define __USE_SUNOS_SOCKETS__ // msghdr 22 | #define __USE_LEGACY_PROTOTYPES__ // iovec 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | enum { 56 | sizeofPtr = sizeof(void*), 57 | }; 58 | 59 | union sockaddr_all { 60 | struct sockaddr s1; // this one gets used for fields 61 | struct sockaddr_in s2; // these pad it out 62 | struct sockaddr_in6 s3; 63 | struct sockaddr_un s4; 64 | struct sockaddr_dl s5; 65 | }; 66 | 67 | struct sockaddr_any { 68 | struct sockaddr addr; 69 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 70 | }; 71 | 72 | */ 73 | import "C" 74 | 75 | // Machine characteristics; for internal use. 76 | 77 | const ( 78 | sizeofPtr = C.sizeofPtr 79 | sizeofShort = C.sizeof_short 80 | sizeofInt = C.sizeof_int 81 | sizeofLong = C.sizeof_long 82 | sizeofLongLong = C.sizeof_longlong 83 | PathMax = C.PATH_MAX 84 | ) 85 | 86 | // Basic types 87 | 88 | type ( 89 | _C_short C.short 90 | _C_int C.int 91 | _C_long C.long 92 | _C_long_long C.longlong 93 | ) 94 | 95 | // Time 96 | 97 | type Timespec C.struct_timespec 98 | 99 | type Timeval C.struct_timeval 100 | 101 | type Timeval32 C.struct_timeval32 102 | 103 | type Tms C.struct_tms 104 | 105 | type Utimbuf C.struct_utimbuf 106 | 107 | // Processes 108 | 109 | type Rusage C.struct_rusage 110 | 111 | type Rlimit C.struct_rlimit 112 | 113 | type _Gid_t C.gid_t 114 | 115 | // Files 116 | 117 | const ( // Directory mode bits 118 | S_IFMT = C.S_IFMT 119 | S_IFIFO = C.S_IFIFO 120 | S_IFCHR = C.S_IFCHR 121 | S_IFDIR = C.S_IFDIR 122 | S_IFBLK = C.S_IFBLK 123 | S_IFREG = C.S_IFREG 124 | S_IFLNK = C.S_IFLNK 125 | S_IFSOCK = C.S_IFSOCK 126 | S_ISUID = C.S_ISUID 127 | S_ISGID = C.S_ISGID 128 | S_ISVTX = C.S_ISVTX 129 | S_IRUSR = C.S_IRUSR 130 | S_IWUSR = C.S_IWUSR 131 | S_IXUSR = C.S_IXUSR 132 | ) 133 | 134 | type Stat_t C.struct_stat 135 | 136 | type Flock_t C.struct_flock 137 | 138 | type Dirent C.struct_dirent 139 | 140 | // Sockets 141 | 142 | type RawSockaddrInet4 C.struct_sockaddr_in 143 | 144 | type RawSockaddrInet6 C.struct_sockaddr_in6 145 | 146 | type RawSockaddrUnix C.struct_sockaddr_un 147 | 148 | type RawSockaddrDatalink C.struct_sockaddr_dl 149 | 150 | type RawSockaddr C.struct_sockaddr 151 | 152 | type RawSockaddrAny C.struct_sockaddr_any 153 | 154 | type _Socklen C.socklen_t 155 | 156 | type Linger C.struct_linger 157 | 158 | type Iovec C.struct_iovec 159 | 160 | type IPMreq C.struct_ip_mreq 161 | 162 | type IPv6Mreq C.struct_ipv6_mreq 163 | 164 | type Msghdr C.struct_msghdr 165 | 166 | type Cmsghdr C.struct_cmsghdr 167 | 168 | type Inet6Pktinfo C.struct_in6_pktinfo 169 | 170 | type IPv6MTUInfo C.struct_ip6_mtuinfo 171 | 172 | type ICMPv6Filter C.struct_icmp6_filter 173 | 174 | const ( 175 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 176 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 177 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 178 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 179 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 180 | SizeofLinger = C.sizeof_struct_linger 181 | SizeofIPMreq = C.sizeof_struct_ip_mreq 182 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 183 | SizeofMsghdr = C.sizeof_struct_msghdr 184 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 185 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 186 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 187 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 188 | ) 189 | 190 | // Select 191 | 192 | type FdSet C.fd_set 193 | 194 | // Misc 195 | 196 | type Utsname C.struct_utsname 197 | 198 | type Ustat_t C.struct_ustat 199 | 200 | const ( 201 | AT_FDCWD = C.AT_FDCWD 202 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 203 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 204 | AT_REMOVEDIR = C.AT_REMOVEDIR 205 | AT_EACCESS = C.AT_EACCESS 206 | ) 207 | 208 | // Routing and interface messages 209 | 210 | const ( 211 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 212 | SizeofIfData = C.sizeof_struct_if_data 213 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 214 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 215 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 216 | ) 217 | 218 | type IfMsghdr C.struct_if_msghdr 219 | 220 | type IfData C.struct_if_data 221 | 222 | type IfaMsghdr C.struct_ifa_msghdr 223 | 224 | type RtMsghdr C.struct_rt_msghdr 225 | 226 | type RtMetrics C.struct_rt_metrics 227 | 228 | // Berkeley packet filter 229 | 230 | const ( 231 | SizeofBpfVersion = C.sizeof_struct_bpf_version 232 | SizeofBpfStat = C.sizeof_struct_bpf_stat 233 | SizeofBpfProgram = C.sizeof_struct_bpf_program 234 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 235 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 236 | ) 237 | 238 | type BpfVersion C.struct_bpf_version 239 | 240 | type BpfStat C.struct_bpf_stat 241 | 242 | type BpfProgram C.struct_bpf_program 243 | 244 | type BpfInsn C.struct_bpf_insn 245 | 246 | type BpfTimeval C.struct_bpf_timeval 247 | 248 | type BpfHdr C.struct_bpf_hdr 249 | 250 | // sysconf information 251 | 252 | const _SC_PAGESIZE = C._SC_PAGESIZE 253 | 254 | // Terminal handling 255 | 256 | type Termios C.struct_termios 257 | 258 | type Termio C.struct_termio 259 | 260 | type Winsize C.struct_winsize 261 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 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,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Jan Bruder 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # These env vars have to be set in the CI 2 | # GITHUB_TOKEN 3 | # DOCKER_HUB_TOKEN 4 | 5 | .PHONY: build deps test release clean push image ci-compile build-dir ci-dist dist-dir ci-release version help 6 | 7 | PROJECT := rancher-gen 8 | PLATFORM := linux 9 | ARCH := amd64 10 | DOCKER_IMAGE := janeczku/$(PROJECT) 11 | 12 | VERSION := $(shell cat VERSION) 13 | GITSHA := $(shell git rev-parse --short HEAD) 14 | 15 | all: help 16 | 17 | help: 18 | @echo "make build - build binary for the target environment" 19 | @echo "make deps - install build dependencies" 20 | @echo "make vet - run vet & gofmt checks" 21 | @echo "make test - run tests" 22 | @echo "make clean - Duh!" 23 | @echo "make release - tag with version and trigger CI release build" 24 | @echo "make image - build release image" 25 | @echo "make dev-image - build development image" 26 | @echo "make dockerhub - build and push image to Docker Hub" 27 | @echo "make version - show app version" 28 | 29 | build: build-dir 30 | CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) godep go build -ldflags "-X main.Version=$(VERSION) -X main.GitSHA=$(GITSHA)" -o build/$(PROJECT)-$(PLATFORM)-$(ARCH) 31 | 32 | deps: 33 | go get github.com/tools/godep 34 | go get github.com/c4milo/github-release 35 | 36 | vet: 37 | scripts/vet 38 | 39 | test: 40 | godep go test -v ./... 41 | 42 | release: 43 | git tag `cat VERSION` 44 | git push origin master --tags 45 | 46 | clean: 47 | go clean 48 | rm -fr ./build 49 | rm -fr ./dist 50 | 51 | dockerhub: image 52 | @echo "Pushing $(DOCKER_IMAGE):$(VERSION)" 53 | docker push $(DOCKER_IMAGE):$(VERSION) 54 | 55 | image: 56 | docker build -t $(DOCKER_IMAGE):$(VERSION) -f Dockerfile . 57 | 58 | dev-image: 59 | docker build -t $(DOCKER_IMAGE):dev -f Dockerfile.dev . 60 | 61 | version: 62 | @echo $(VERSION) $(GITSHA) 63 | 64 | ci-compile: build-dir 65 | CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) godep go build -ldflags "-X main.Version=$(VERSION) -X main.GitSHA=$(GITSHA) -w -s" -a -o build/$(PROJECT)-$(PLATFORM)-$(ARCH)/$(PROJECT) 66 | 67 | build-dir: 68 | @rm -rf build && mkdir build 69 | 70 | dist-dir: 71 | @rm -rf dist && mkdir dist 72 | 73 | ci-dist: ci-compile dist-dir 74 | $(eval FILES := $(shell ls build)) 75 | @for f in $(FILES); do \ 76 | (cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \ 77 | (cd $(shell pwd)/dist && shasum -a 256 $$f.tar.gz > $$f.sha256); \ 78 | (cd $(shell pwd)/dist && md5sum $$f.tar.gz > $$f.md5); \ 79 | echo $$f; \ 80 | done 81 | @cp -r $(shell pwd)/dist/* $(CIRCLE_ARTIFACTS) 82 | ls $(CIRCLE_ARTIFACTS) 83 | 84 | ci-release: 85 | @previous_tag=$$(git describe --abbrev=0 --tags $(VERSION)^); \ 86 | comparison="$$previous_tag..HEAD"; \ 87 | if [ -z "$$previous_tag" ]; then comparison=""; fi; \ 88 | changelog=$$(git log $$comparison --oneline --no-merges --reverse); \ 89 | github-release $(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME) $(VERSION) master "**Changelog**
$$changelog" 'dist/*' 90 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | v0.2.0 2 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | environment: 3 | IMPORT_PATH: "github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" 4 | DOCKER_HUB_URI: https://registry.hub.docker.com/u/janeczku/rancher-gen/trigger 5 | 6 | general: 7 | artifacts: 8 | - "dist/*.tar.gz" 9 | - "dist/*.sha512" 10 | - "dist/*.md5" 11 | 12 | checkout: 13 | post: 14 | - git config user.name "Circle CI Build Bot" 15 | - git config user.email "no-reply@circleci.com" 16 | - git remote -v 17 | - git fetch --tags 18 | 19 | dependencies: 20 | pre: 21 | - go version 22 | - make deps 23 | 24 | test: 25 | pre: 26 | - make vet 27 | override: 28 | - make test 29 | post: 30 | - make ci-dist 31 | 32 | deployment: 33 | release: 34 | tag: /v.*/ 35 | owner: janeczku 36 | commands: 37 | - make ci-release 38 | - curl --data "docker_tag=latest" -X POST ${DOCKER_HUB_URI}/${DOCKER_HUB_TOKEN}/ 39 | - sleep 90 40 | - curl --data "source_type=Tag&source_name=${CIRCLE_TAG}" -X POST ${DOCKER_HUB_URI}/${DOCKER_HUB_TOKEN}/ 41 | - echo `git name-rev --tags --name-only $(git rev-parse HEAD)` 42 | - echo tag ${CIRCLE_TAG} 43 | -------------------------------------------------------------------------------- /config.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "io/ioutil" 7 | "os" 8 | "strconv" 9 | 10 | "github.com/BurntSushi/toml" 11 | log "github.com/Sirupsen/logrus" 12 | ) 13 | 14 | type Config struct { 15 | Interval int `toml:"interval"` 16 | MetadataVersion string `toml:"metadata-version"` 17 | LogLevel string `toml:"log-level"` 18 | OneTime bool `toml:"onetime"` 19 | IncludeInactive bool `toml:"include-inactive"` 20 | Templates []Template `toml:"template"` 21 | } 22 | 23 | type Template struct { 24 | Source string `toml:"source"` 25 | Dest string `toml:"dest"` 26 | CheckCmd string `toml:"check-cmd"` 27 | NotifyCmd string `toml:"notify-cmd"` 28 | NotifyOutput bool `toml:"notify-output"` 29 | } 30 | 31 | func initConfig() (*Config, error) { 32 | config := Config{ 33 | MetadataVersion: "latest", 34 | Interval: 5, 35 | LogLevel: "info", 36 | } 37 | 38 | if len(configFile) > 0 { 39 | log.Debugf("Loading config from file %s", configFile) 40 | err := setConfigFromFile(configFile, &config) 41 | if err != nil { 42 | return nil, fmt.Errorf("Could not load config file: %v", err) 43 | } 44 | } else { 45 | setTemplateFromFlags(&config) 46 | } 47 | 48 | overwriteConfigFromEnv(&config) 49 | overwriteConfigFromFlags(&config) 50 | 51 | if config.Interval == 0 { 52 | return nil, fmt.Errorf("Interval must be greater than 0") 53 | } 54 | 55 | lvl, err := log.ParseLevel(config.LogLevel) 56 | if err != nil { 57 | return nil, fmt.Errorf("Invalid log level: %s", config.LogLevel) 58 | } 59 | 60 | log.SetLevel(lvl) 61 | 62 | return &config, nil 63 | } 64 | 65 | func setConfigFromFile(path string, conf *Config) error { 66 | buf, err := ioutil.ReadFile(path) 67 | if err != nil { 68 | return err 69 | } 70 | 71 | _, err = toml.Decode(string(buf), conf) 72 | if err != nil { 73 | return err 74 | } 75 | 76 | return nil 77 | } 78 | 79 | func setTemplateFromFlags(conf *Config) { 80 | tmpl := Template{ 81 | Source: flag.Arg(0), 82 | Dest: flag.Arg(1), 83 | CheckCmd: checkCmd, 84 | NotifyCmd: notifyCmd, 85 | NotifyOutput: notifyOutput, 86 | } 87 | conf.Templates = []Template{tmpl} 88 | } 89 | 90 | func overwriteConfigFromFlags(conf *Config) { 91 | flag.Visit(func(f *flag.Flag) { 92 | switch f.Name { 93 | case "interval": 94 | conf.Interval = interval 95 | case "metadata-version": 96 | conf.MetadataVersion = metadataVersion 97 | case "onetime": 98 | conf.OneTime = onetime 99 | case "include-inactive": 100 | conf.IncludeInactive = includeInactive 101 | case "log-level": 102 | conf.LogLevel = logLevel 103 | } 104 | }) 105 | } 106 | 107 | func overwriteConfigFromEnv(conf *Config) { 108 | var env string 109 | if env = os.Getenv("RANCHER_GEN_LOGLEVEL"); len(env) > 0 { 110 | conf.LogLevel = env 111 | } 112 | if env = os.Getenv("RANCHER_GEN_INTERVAL"); len(env) > 0 { 113 | interval, err := strconv.Atoi(env) 114 | if err != nil { 115 | conf.Interval = interval 116 | } else { 117 | log.Warnf("Invalid value for environment variable 'RANCHER_GEN_INTERVAL': %s", env) 118 | } 119 | } 120 | if env = os.Getenv("RANCHER_GEN_METADATA_VER"); len(env) > 0 { 121 | conf.MetadataVersion = env 122 | } 123 | if env = os.Getenv("RANCHER_GEN_ONETIME"); len(env) > 0 { 124 | conf.OneTime = true 125 | } 126 | if env = os.Getenv("RANCHER_GEN_INACTIVE"); len(env) > 0 { 127 | conf.IncludeInactive = true 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /examples/config.toml.sample: -------------------------------------------------------------------------------- 1 | metadata-version = "2015-12-19" 2 | log-level = "debug" 3 | interval = 30 4 | onetime = false 5 | 6 | [[template]] 7 | source = "/etc/rancher-gen/nginx.tmpl" 8 | dest = "/etc/nginx/nginx.conf" 9 | check-cmd = "/usr/sbin/nginx -t -c {{staging}}" 10 | notify-cmd = "/usr/sbin/nginx -s reload" 11 | notify-output = true 12 | 13 | [[template]] 14 | source = "/etc/rancher-gen/apache.tmpl" 15 | dest = "/etc/apache2/sites-available/default" 16 | notify-cmd = "/usr/sbin/apachectl graceful" 17 | notify-output = false 18 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | log "github.com/Sirupsen/logrus" 9 | ) 10 | 11 | var ( 12 | // Must be set at build time 13 | Version string = "UNDEFINED" 14 | GitSHA string = "UNDEFINED" 15 | 16 | configFile string 17 | metadataVersion string 18 | logLevel string 19 | checkCmd string 20 | notifyCmd string 21 | onetime bool 22 | showVersion bool 23 | notifyOutput bool 24 | includeInactive bool 25 | interval int 26 | ) 27 | 28 | func init() { 29 | log.SetFormatter(&log.TextFormatter{DisableTimestamp: true}) 30 | log.SetOutput(os.Stdout) 31 | 32 | flag.StringVar(&configFile, "config", "", "Path to optional config file") 33 | flag.StringVar(&metadataVersion, "metadata-version", "latest", "Metadata version to use for querying the Metadata API") 34 | flag.IntVar(&interval, "interval", 60, "Interval (in seconds) for polling the Metadata API for changes") 35 | flag.BoolVar(&includeInactive, "include-inactive", false, "Not yet implemented") 36 | flag.BoolVar(&onetime, "onetime", false, "Process all templates once and exit") 37 | flag.StringVar(&logLevel, "log-level", "info", "Verbosity of log output (debug,info,warn,error)") 38 | flag.StringVar(&checkCmd, "check-cmd", "", "Command to check the content before updating the destination file.") 39 | flag.StringVar(¬ifyCmd, "notify-cmd", "", "Command to run after the destination file has been updated.") 40 | flag.BoolVar(¬ifyOutput, "notify-output", false, "Print the result of the notify command to STDOUT") 41 | flag.BoolVar(&showVersion, "version", false, "Show application version and exit") 42 | flag.Usage = printUsage 43 | flag.Parse() 44 | } 45 | 46 | func printUsage() { 47 | fmt.Println(`Usage: rancher-gen [options] source [destination] 48 | 49 | Options:`) 50 | flag.VisitAll(func(fg *flag.Flag) { 51 | fmt.Printf("\t--%s=%s\n\t\t%s\n", fg.Name, fg.DefValue, fg.Usage) 52 | }) 53 | fmt.Println(` 54 | Arguments: 55 | source - Path to the template file 56 | dest - Path to the output file. If ommited result is printed to STDOUT.`) 57 | } 58 | 59 | func main() { 60 | if showVersion { 61 | fmt.Printf("rancher-gen version %s (%s) \n", Version, GitSHA) 62 | os.Exit(0) 63 | } 64 | 65 | if flag.NArg() < 1 && len(configFile) == 0 { 66 | flag.Usage() 67 | os.Exit(1) 68 | } 69 | 70 | log.Infof("Starting rancher-gen %s (%s)", Version, GitSHA) 71 | 72 | conf, err := initConfig() 73 | if err != nil { 74 | log.Fatal(err.Error()) 75 | } 76 | 77 | r, err := NewRunner(conf) 78 | if err != nil { 79 | log.Fatal(err.Error()) 80 | } 81 | 82 | if err := r.Run(); err != nil { 83 | log.Fatal(err) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /scripts/vet: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # validates that the project is clean of formatting and vet errors. 4 | # symlink as .git/hooks/pre-commit to use as a pre-commit check. 5 | # 6 | 7 | gofiles=$(find . ! -path "*/_*" -name "*.go") 8 | [ -z "$gofiles" ] && exit 0 9 | 10 | function checkfmt() { 11 | unformatted=$(gofmt -l $*) 12 | [ -z "$unformatted" ] && return 0 13 | 14 | echo >&2 "Go files must be formatted with gofmt. Please run:" 15 | for fn in $unformatted; do 16 | echo >&2 " gofmt -w $PWD/$fn" 17 | done 18 | 19 | return 1 20 | } 21 | 22 | function checkvet() { 23 | unvetted=$(go vet ./... 2>&1 | grep -v "exit status") 24 | [ -z "$unvetted" ] && return 0 25 | 26 | echo >&2 "Go files must be vetted. Check these problems:" 27 | IFS=$'\n' 28 | for line in $unvetted; do 29 | echo >&2 " $line" 30 | done 31 | unset IFS 32 | 33 | return 1 34 | } 35 | 36 | checkfmt $gofiles || fail=yes 37 | checkvet $gofiles || fail=yes 38 | 39 | [ -z "$fail" ] || exit 1 -------------------------------------------------------------------------------- /template_context.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | type NotFoundError struct { 10 | msg string 11 | } 12 | 13 | func (e NotFoundError) Error() string { 14 | return e.msg 15 | } 16 | 17 | type TemplateContext struct { 18 | Services []Service 19 | Containers []Container 20 | Hosts []Host 21 | Self Self 22 | } 23 | 24 | // GetHost returns the Host with the given UUID. If the argument is omitted 25 | // the local host is returned. 26 | func (c *TemplateContext) GetHost(v ...string) (Host, error) { 27 | uuid := "" 28 | if len(v) > 0 { 29 | uuid = v[0] 30 | } 31 | if uuid == "" { 32 | uuid = c.Self.HostUUID 33 | } 34 | 35 | for _, h := range c.Hosts { 36 | if strings.EqualFold(uuid, h.UUID) { 37 | return h, nil 38 | } 39 | } 40 | 41 | return Host{}, NotFoundError{"(host) could not find host by UUID: " + uuid} 42 | } 43 | 44 | // GetService returns the service matching the given name. 45 | // It expects a string in the form 'service-name[.stack-name]'. 46 | // If the argument is an empty string it returns the service of the current container. 47 | func (c *TemplateContext) GetService(v ...string) (Service, error) { 48 | identifier := "" 49 | if len(v) > 0 { 50 | identifier = v[0] 51 | } 52 | var stack, service string 53 | if identifier == "" { 54 | stack = c.Self.Stack 55 | service = c.Self.Service 56 | } else { 57 | parts := strings.Split(identifier, ".") 58 | switch len(parts) { 59 | case 1: 60 | service = parts[0] 61 | stack = c.Self.Stack 62 | case 2: 63 | service = parts[0] 64 | stack = parts[1] 65 | default: 66 | return Service{}, fmt.Errorf("(service) invalid service identifier '%s'", identifier) 67 | } 68 | } 69 | 70 | for _, s := range c.Services { 71 | if strings.EqualFold(s.Name, service) && strings.EqualFold(s.Stack, stack) { 72 | return s, nil 73 | } 74 | } 75 | 76 | return Service{}, NotFoundError{"(service) could not find service by identifier: " + identifier} 77 | } 78 | 79 | func (c *TemplateContext) GetHosts(selectors ...string) ([]Host, error) { 80 | if len(selectors) == 0 { 81 | return c.Hosts, nil 82 | } 83 | 84 | labels := LabelMap{} 85 | 86 | for _, f := range selectors { 87 | if !strings.HasPrefix(f, "@") { 88 | return nil, fmt.Errorf("(hosts) invalid argument '%s'", f) 89 | } 90 | f = f[1:len(f)] 91 | parts := strings.Split(f, "=") 92 | if len(parts) != 2 { 93 | return nil, fmt.Errorf("(hosts) malformed label selector '%s'", f) 94 | } 95 | labels[parts[0]] = parts[1] 96 | } 97 | 98 | return filterHostsByLabel(c.Hosts, labels), nil 99 | } 100 | 101 | func (c *TemplateContext) GetServices(selectors ...string) ([]Service, error) { 102 | if len(selectors) == 0 { 103 | return c.Services, nil 104 | } 105 | 106 | labels := LabelMap{} 107 | var stack string 108 | 109 | for _, f := range selectors { 110 | switch f[:1] { 111 | case ".": 112 | if len(stack) > 0 { 113 | return nil, fmt.Errorf("(services) invalid use of multiple stack selectors '%s'", f) 114 | } 115 | stack = f[1:len(f)] 116 | case "@": 117 | parts := strings.Split(f[1:len(f)], "=") 118 | if len(parts) != 2 { 119 | return nil, fmt.Errorf("(services) malformed label selector '%s'", f) 120 | } 121 | labels[parts[0]] = parts[1] 122 | default: 123 | return nil, fmt.Errorf("(services) invalid argument '%s'", f) 124 | } 125 | } 126 | 127 | services := c.Services 128 | 129 | if len(stack) > 0 { 130 | services = filterServicesByStack(services, stack) 131 | } 132 | if len(labels) > 0 { 133 | services = filterServicesByLabel(services, labels) 134 | } 135 | 136 | return services, nil 137 | } 138 | 139 | // returns true if the LabelMap needle is a subset of the LabelMap stack. 140 | // the needle map may contain regex in it's values. 141 | func inLabelMap(stack, needle LabelMap) bool { 142 | match := true 143 | for k, v := range needle { 144 | if stack.Exists(k) { 145 | if strings.EqualFold(stack.GetValue(k), v) { 146 | continue 147 | } 148 | // regex match 149 | rx, err := regexp.Compile(v) 150 | if err == nil && rx.MatchString(stack.GetValue(k)) { 151 | continue 152 | } 153 | } 154 | match = false 155 | break 156 | } 157 | return match 158 | } 159 | 160 | func filterHostsByLabel(hosts []Host, labels LabelMap) []Host { 161 | result := make([]Host, 0) 162 | for _, h := range hosts { 163 | if ok := inLabelMap(h.Labels, labels); ok { 164 | result = append(result, h) 165 | } 166 | } 167 | return result 168 | } 169 | 170 | func filterServicesByLabel(services []Service, labels LabelMap) []Service { 171 | result := make([]Service, 0) 172 | for _, s := range services { 173 | if ok := inLabelMap(s.Labels, labels); ok { 174 | result = append(result, s) 175 | } 176 | } 177 | return result 178 | } 179 | 180 | func filterServicesByStack(services []Service, stack string) []Service { 181 | result := make([]Service, 0) 182 | for _, s := range services { 183 | if strings.EqualFold(s.Stack, stack) { 184 | result = append(result, s) 185 | } 186 | } 187 | return result 188 | } 189 | -------------------------------------------------------------------------------- /template_functions.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | "regexp" 8 | "strings" 9 | "text/template" 10 | "time" 11 | 12 | log "github.com/Sirupsen/logrus" 13 | ) 14 | 15 | func newFuncMap(ctx *TemplateContext) template.FuncMap { 16 | return template.FuncMap{ 17 | // Utility funcs 18 | "base": path.Base, 19 | "dir": path.Dir, 20 | "env": os.Getenv, 21 | "timestamp": time.Now, 22 | "split": strings.Split, 23 | "join": strings.Join, 24 | "toUpper": strings.ToUpper, 25 | "toLower": strings.ToLower, 26 | "contains": strings.Contains, 27 | "replace": strings.Replace, 28 | 29 | // Service funcs 30 | "host": hostFunc(ctx), 31 | "hosts": hostsFunc(ctx), 32 | "service": serviceFunc(ctx), 33 | "services": servicesFunc(ctx), 34 | "whereLabelExists": whereLabelExists, 35 | "whereLabelEquals": whereLabelEquals, 36 | "whereLabelMatches": whereLabelEquals, 37 | "groupByLabel": groupByLabel, 38 | } 39 | } 40 | 41 | // serviceFunc returns a single service given a string argument in the form 42 | // [.]. 43 | func serviceFunc(ctx *TemplateContext) func(...string) (interface{}, error) { 44 | return func(s ...string) (result interface{}, err error) { 45 | result, err = ctx.GetService(s...) 46 | if _, ok := err.(NotFoundError); ok { 47 | log.Debug(err) 48 | return nil, nil 49 | } 50 | return 51 | } 52 | } 53 | 54 | // servicesFunc returns all available services, optionally filtered by stack 55 | // name or label values. 56 | func servicesFunc(ctx *TemplateContext) func(...string) (interface{}, error) { 57 | return func(s ...string) (interface{}, error) { 58 | return ctx.GetServices(s...) 59 | } 60 | } 61 | 62 | // hostFunc returns a single host given it's UUID. 63 | func hostFunc(ctx *TemplateContext) func(...string) (interface{}, error) { 64 | return func(s ...string) (result interface{}, err error) { 65 | result, err = ctx.GetHost(s...) 66 | if _, ok := err.(NotFoundError); ok { 67 | log.Debug(err) 68 | return nil, nil 69 | } 70 | return 71 | } 72 | } 73 | 74 | // hostsFunc returns all available hosts, optionally filtered by label value. 75 | func hostsFunc(ctx *TemplateContext) func(...string) (interface{}, error) { 76 | return func(s ...string) (interface{}, error) { 77 | return ctx.GetHosts(s...) 78 | } 79 | } 80 | 81 | // groupByLabel takes a label key and a slice of services or hosts and returns a map based 82 | // on the values of the label. 83 | // 84 | // The map key is a string representing the label value. The map value is a 85 | // slice of services or hosts that have the corresponding label value. 86 | // Example: 87 | // {{range $labelValue, $containers := svc.Containers | groupByLabel "foo"}} 88 | func groupByLabel(label string, in interface{}) (map[string][]interface{}, error) { 89 | m := make(map[string][]interface{}) 90 | 91 | if in == nil { 92 | return m, fmt.Errorf("(groupByLabel) input is nil") 93 | } 94 | 95 | switch typed := in.(type) { 96 | case []Service: 97 | for _, s := range typed { 98 | value, ok := s.Labels[label] 99 | if ok && len(value) > 0 { 100 | m[value] = append(m[value], s) 101 | } 102 | } 103 | case []Container: 104 | for _, c := range typed { 105 | value, ok := c.Labels[label] 106 | if ok && len(value) > 0 { 107 | m[value] = append(m[value], c) 108 | } 109 | } 110 | case []Host: 111 | for _, h := range typed { 112 | value, ok := h.Labels[label] 113 | if ok && len(value) > 0 { 114 | m[value] = append(m[value], h) 115 | } 116 | } 117 | default: 118 | return m, fmt.Errorf("(groupByLabel) invalid input type %T", in) 119 | } 120 | 121 | return m, nil 122 | } 123 | 124 | func whereLabel(funcName string, in interface{}, label string, test func(string, bool) bool) ([]interface{}, error) { 125 | result := make([]interface{}, 0) 126 | if in == nil { 127 | return result, fmt.Errorf("(%s) input is nil", funcName) 128 | } 129 | if label == "" { 130 | return result, fmt.Errorf("(%s) label is empty", funcName) 131 | } 132 | 133 | switch typed := in.(type) { 134 | case []Service: 135 | for _, s := range typed { 136 | value, ok := s.Labels[label] 137 | if test(value, ok) { 138 | result = append(result, s) 139 | } 140 | } 141 | case []Container: 142 | for _, c := range typed { 143 | value, ok := c.Labels[label] 144 | if test(value, ok) { 145 | result = append(result, c) 146 | } 147 | } 148 | case []Host: 149 | for _, s := range typed { 150 | value, ok := s.Labels[label] 151 | if test(value, ok) { 152 | result = append(result, s) 153 | } 154 | } 155 | default: 156 | return result, fmt.Errorf("(%s) invalid input type %T", funcName, in) 157 | } 158 | 159 | return result, nil 160 | } 161 | 162 | // selects services or hosts from the input that have the given label 163 | func whereLabelExists(label string, in interface{}) ([]interface{}, error) { 164 | return whereLabel("whereLabelExists", in, label, func(_ string, ok bool) bool { 165 | return ok 166 | }) 167 | } 168 | 169 | // selects services or hosts from the input that have the given label and value 170 | func whereLabelEquals(label, labelValue string, in interface{}) ([]interface{}, error) { 171 | return whereLabel("whereLabelEquals", in, label, func(value string, ok bool) bool { 172 | return ok && strings.EqualFold(value, labelValue) 173 | }) 174 | } 175 | 176 | // selects services or hosts from the input that have the given label whose value matches the regex 177 | func whereLabelMatches(label, pattern string, in interface{}) ([]interface{}, error) { 178 | rx, err := regexp.Compile(pattern) 179 | if err != nil { 180 | return nil, err 181 | } 182 | 183 | return whereLabel("whereLabelMatches", in, label, func(value string, ok bool) bool { 184 | return ok && rx.MatchString(value) 185 | }) 186 | } 187 | -------------------------------------------------------------------------------- /template_types.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Service represents a Rancher service. 4 | type Service struct { 5 | Name string 6 | Stack string 7 | Kind string // service, loadBalancerService 8 | Vip string 9 | Fqdn string 10 | Ports []ServicePort 11 | Labels LabelMap 12 | Metadata MetadataMap 13 | Containers []Container 14 | } 15 | 16 | // Container represents a container belonging to a Rancher Service. 17 | type Container struct { 18 | Name string 19 | Address string 20 | Stack string 21 | Service string 22 | Health string 23 | State string 24 | Labels LabelMap 25 | Host Host 26 | } 27 | 28 | // Host represents a Rancher Host. 29 | type Host struct { 30 | UUID string 31 | Name string 32 | Address string 33 | Hostname string 34 | Labels LabelMap 35 | } 36 | 37 | // Self contains information about the container running this application. 38 | type Self struct { 39 | Stack string 40 | Service string 41 | HostUUID string 42 | } 43 | 44 | // ServicePort represents a port exposed by a service 45 | type ServicePort struct { 46 | PublicPort string 47 | InternalPort string 48 | Protocol string 49 | } 50 | 51 | // LabelMap contains the labels of a service or host. 52 | type LabelMap map[string]string 53 | 54 | // Exists returns true if the Labels contain the given key. 55 | func (l LabelMap) Exists(key string) bool { 56 | _, ok := l[key] 57 | 58 | return ok 59 | } 60 | 61 | // Value returns the value of the given label key. 62 | func (l LabelMap) GetValue(key string, v ...string) string { 63 | if val, ok := l[key]; ok && len(val) > 0 { 64 | return val 65 | } 66 | 67 | if len(v) > 0 { 68 | return v[0] 69 | } 70 | 71 | return "" 72 | } 73 | 74 | // MetadataMap contains the metadata of a service. 75 | type MetadataMap map[string]interface{} 76 | 77 | // Exists returns true if the metadata contains the given key. 78 | func (m MetadataMap) Exists(key string) bool { 79 | _, ok := m[key] 80 | 81 | return ok 82 | } 83 | 84 | // Value returns the value of the given metadata key. 85 | func (m MetadataMap) GetValue(key string, v ...interface{}) interface{} { 86 | if val, ok := m[key]; ok { 87 | return val 88 | } 89 | 90 | if len(v) > 0 { 91 | return v[0] 92 | } 93 | 94 | return "" 95 | } 96 | --------------------------------------------------------------------------------