├── .gitignore ├── F5.md ├── Godeps ├── Godeps.json └── Readme ├── LICENSE ├── README.md ├── allinone.sh ├── apply.sh ├── build.sh ├── cmd ├── apply.go ├── clean.go ├── gen.go ├── oninit.go └── root.go ├── config ├── define ├── define.go └── logo.go ├── docs └── cluster.png ├── install-online.sh ├── main.go ├── out ├── 10-kubeadm.conf ├── calico.yaml ├── calicoctl.yaml ├── dashboard-admin.yaml ├── deploy │ ├── docker │ │ └── Dockerfile │ ├── kube-config │ │ ├── google │ │ │ └── heapster.yaml │ │ ├── influxdb │ │ │ ├── grafana.yaml │ │ │ ├── heapster.yaml │ │ │ └── influxdb.yaml │ │ ├── rbac │ │ │ └── heapster-rbac.yaml │ │ ├── standalone-test │ │ │ ├── heapster-controller.yaml │ │ │ ├── heapster-service.yaml │ │ │ └── heapster-summary-controller.yaml │ │ ├── standalone-with-apiserver │ │ │ ├── common.sh │ │ │ ├── heapster-apiserver-secrets.template │ │ │ ├── heapster-deployment.yaml │ │ │ ├── heapster-service.yaml │ │ │ └── startup.sh │ │ └── standalone │ │ │ └── heapster-controller.yaml │ └── kube.sh ├── etcd-docker-compose-0.yml ├── etcd-docker-compose-1.yml ├── etcd-docker-compose-2.yml ├── grafana.json ├── haproxy.cfg ├── kubeadm.yaml ├── kubeinit.json ├── kubelet.service └── kubernetes-dashboard.yaml ├── pkg ├── apply.go ├── dashboard │ ├── manifast.go │ └── run.go ├── etcd │ ├── manifast.go │ └── run.go ├── ha │ ├── manifast.go │ └── run.go ├── initer.go ├── kubecore │ ├── kubecore.go │ └── manifast.go ├── monitor │ ├── manifast.go │ └── run.go ├── net │ ├── manifast.go │ └── run.go └── utils.go ├── save.sh ├── temp.sh ├── test-alicloud.sh ├── test.sh └── vendor ├── 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 ├── fsnotify │ └── fsnotify │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── AUTHORS │ │ ├── CHANGELOG.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── fen.go │ │ ├── fsnotify.go │ │ ├── inotify.go │ │ ├── inotify_poller.go │ │ ├── kqueue.go │ │ ├── open_mode_bsd.go │ │ ├── open_mode_darwin.go │ │ └── windows.go ├── hashicorp │ └── hcl │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── appveyor.yml │ │ ├── decoder.go │ │ ├── hcl.go │ │ ├── hcl │ │ ├── ast │ │ │ ├── ast.go │ │ │ └── walk.go │ │ ├── parser │ │ │ ├── error.go │ │ │ └── parser.go │ │ ├── scanner │ │ │ └── scanner.go │ │ ├── strconv │ │ │ └── quote.go │ │ └── token │ │ │ ├── position.go │ │ │ └── token.go │ │ ├── json │ │ ├── parser │ │ │ ├── flatten.go │ │ │ └── parser.go │ │ ├── scanner │ │ │ └── scanner.go │ │ └── token │ │ │ ├── position.go │ │ │ └── token.go │ │ ├── lex.go │ │ └── parse.go ├── inconshreveable │ └── mousetrap │ │ ├── LICENSE │ │ ├── README.md │ │ ├── trap_others.go │ │ ├── trap_windows.go │ │ └── trap_windows_1.4.go ├── magiconair │ └── properties │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── decode.go │ │ ├── doc.go │ │ ├── integrate.go │ │ ├── lex.go │ │ ├── load.go │ │ ├── parser.go │ │ ├── properties.go │ │ └── rangecheck.go ├── mitchellh │ └── mapstructure │ │ ├── LICENSE │ │ ├── README.md │ │ ├── decode_hooks.go │ │ ├── error.go │ │ └── mapstructure.go └── spf13 │ ├── cast │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── cast.go │ └── caste.go │ ├── cobra │ ├── .gitignore │ ├── .mailmap │ ├── .travis.yml │ ├── LICENSE.txt │ ├── README.md │ ├── bash_completions.go │ ├── bash_completions.md │ ├── cobra.go │ ├── command.go │ ├── command_notwin.go │ └── command_win.go │ ├── jwalterweatherman │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ └── thatswhyyoualwaysleaveanote.go │ ├── pflag │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── bool.go │ ├── count.go │ ├── duration.go │ ├── flag.go │ ├── float32.go │ ├── float64.go │ ├── golangflag.go │ ├── int.go │ ├── int32.go │ ├── int64.go │ ├── int8.go │ ├── int_slice.go │ ├── ip.go │ ├── ipmask.go │ ├── ipnet.go │ ├── string.go │ ├── string_slice.go │ ├── uint.go │ ├── uint16.go │ ├── uint32.go │ ├── uint64.go │ └── uint8.go │ └── viper │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── flags.go │ ├── nohup.out │ ├── util.go │ └── viper.go ├── golang.org └── x │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_386.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_ppc64x.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 │ ├── 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 │ ├── 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_386.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_ppc64x.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_386.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_ppc64.go │ ├── zerrors_linux_ppc64le.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_386.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_ppc64.go │ ├── zsyscall_linux_ppc64le.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_386.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_ppc64.go │ ├── zsysnum_linux_ppc64le.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_386.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_ppc64.go │ ├── ztypes_linux_ppc64le.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 └── gopkg.in └── yaml.v2 ├── .travis.yml ├── LICENSE ├── LICENSE.libyaml ├── README.md ├── apic.go ├── decode.go ├── emitterc.go ├── encode.go ├── parserc.go ├── readerc.go ├── resolve.go ├── scannerc.go ├── sorter.go ├── writerc.go ├── yaml.go ├── yamlh.go └── yamlprivateh.go /.gitignore: -------------------------------------------------------------------------------- 1 | *swp 2 | kubeinit 3 | image 4 | bin 5 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/fanux/kubeinit", 3 | "GoVersion": "go1.6", 4 | "GodepVersion": "v79", 5 | "Deps": [ 6 | { 7 | "ImportPath": "github.com/BurntSushi/toml", 8 | "Comment": "v0.2.0-9-gf0aeabc", 9 | "Rev": "f0aeabca5a127c4078abb8c8d64298b147264b55" 10 | }, 11 | { 12 | "ImportPath": "github.com/fsnotify/fsnotify", 13 | "Comment": "v1.3.0", 14 | "Rev": "30411dbcefb7a1da7e84f75530ad3abe4011b4f8" 15 | }, 16 | { 17 | "ImportPath": "github.com/hashicorp/hcl", 18 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 19 | }, 20 | { 21 | "ImportPath": "github.com/hashicorp/hcl/hcl/ast", 22 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 23 | }, 24 | { 25 | "ImportPath": "github.com/hashicorp/hcl/hcl/parser", 26 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 27 | }, 28 | { 29 | "ImportPath": "github.com/hashicorp/hcl/hcl/scanner", 30 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 31 | }, 32 | { 33 | "ImportPath": "github.com/hashicorp/hcl/hcl/strconv", 34 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 35 | }, 36 | { 37 | "ImportPath": "github.com/hashicorp/hcl/hcl/token", 38 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 39 | }, 40 | { 41 | "ImportPath": "github.com/hashicorp/hcl/json/parser", 42 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 43 | }, 44 | { 45 | "ImportPath": "github.com/hashicorp/hcl/json/scanner", 46 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 47 | }, 48 | { 49 | "ImportPath": "github.com/hashicorp/hcl/json/token", 50 | "Rev": "9a905a34e6280ce905da1a32344b25e81011197a" 51 | }, 52 | { 53 | "ImportPath": "github.com/inconshreveable/mousetrap", 54 | "Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" 55 | }, 56 | { 57 | "ImportPath": "github.com/magiconair/properties", 58 | "Comment": "v1.7.0", 59 | "Rev": "c265cfa48dda6474e208715ca93e987829f572f8" 60 | }, 61 | { 62 | "ImportPath": "github.com/mitchellh/mapstructure", 63 | "Rev": "740c764bc6149d3f1806231418adb9f52c11bcbf" 64 | }, 65 | { 66 | "ImportPath": "github.com/spf13/cast", 67 | "Rev": "27b586b42e29bec072fe7379259cc719e1289da6" 68 | }, 69 | { 70 | "ImportPath": "github.com/spf13/cobra", 71 | "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" 72 | }, 73 | { 74 | "ImportPath": "github.com/spf13/jwalterweatherman", 75 | "Rev": "33c24e77fb80341fe7130ee7c594256ff08ccc46" 76 | }, 77 | { 78 | "ImportPath": "github.com/spf13/pflag", 79 | "Rev": "08b1a584251b5b62f458943640fc8ebd4d50aaa5" 80 | }, 81 | { 82 | "ImportPath": "github.com/spf13/viper", 83 | "Rev": "c1ccc378a054ea8d4e38d8c67f6938d4760b53dd" 84 | }, 85 | { 86 | "ImportPath": "golang.org/x/sys/unix", 87 | "Rev": "833a04a10549a95dc34458c195cbad61bbb6cb4d" 88 | }, 89 | { 90 | "ImportPath": "gopkg.in/yaml.v2", 91 | "Rev": "a83829b6f1293c91addabc89d0571c246397bbf4" 92 | } 93 | ] 94 | } 95 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | _ _ _ _ _ 3 | | | | | (_) (_) | 4 | | | ___ _| |__ ___ _ _ __ _| |_ 5 | | |/ / | | | '_ \ / _ \ | '_ \| | __| 6 | | <| |_| | |_) | __/ | | | | | |_ 7 | |_|\_\\__,_|_.__/ \___|_|_| |_|_|\__| 8 | 9 | _| _| _| _| _| 10 | _| _| _| _| _|_|_| _|_| _|_|_| _|_|_|_| 11 | _|_| _| _| _| _| _|_|_|_| _| _| _| _| _| 12 | _| _| _| _| _| _| _| _| _| _| _| _| 13 | _| _| _|_|_| _|_|_| _|_|_| _| _| _| _| _|_| 14 | 15 | __ __ _ _ __ 16 | / /____ __/ /_ ___ (_)___ (_) /_ 17 | / //_/ / / / __ \/ _ \/ / __ \/ / __/ 18 | / ,< / /_/ / /_/ / __/ / / / / / /_ 19 | /_/|_|\__,_/_.___/\___/_/_/ /_/_/\__/ 20 | 21 | _ _ 22 | | | | | 23 | | | __ _ _ __ ___ ___| | ___ __ _ ___ ___ _ __ ___ 24 | | |/ _` | '_ ` _ \ / _ \ |/ _ \/ _` | / __/ _ \| '_ ` _ \ 25 | | | (_| | | | | | | __/ | __/ (_| || (_| (_) | | | | | | 26 | |_|\__,_|_| |_| |_|\___|_|\___|\__, (_)___\___/|_| |_| |_| 27 | __/ | 28 | |___/ 29 | ``` 30 | 31 | ## 2.0版本说明 32 | 此版本将整个项目重构,让其具备更好的灵活性与扩展性 33 | ![](https://github.com/fanux/kubeinit/blob/v2.0/docs/cluster.png) 34 | 35 | ## featrures 36 | - [x] 自动生成多etcd节点compose文件 37 | - [x] 自动生成kubeadm配置 38 | - [x] ~~~自动生成haproxy配置~~~ LVS代替 39 | - [x] 自动检测cgroup driver, 自动生成 kubelet配置文件 40 | 41 | - [x] 自动初始化节点配置,拷贝bin文件,导入镜像 42 | - [x] 自动初始化其它master节点配置 43 | - [x] 自动启动etcd集群,master集群 44 | - [x] 自动启动loadbalance 45 | - [x] 自动join node节点, 修改node join参数为lb 46 | 47 | - [x] 安装calico heapster dashboard 48 | - [ ] 自定义安装addons 49 | 50 | ## create kubernetes HA cluster 51 | > on master0: 52 | 53 | ``` 54 | $ kubeinit run --master 1.1.1.2 --master 1.1.1.3 --master 1.1.1.4 \ 55 | --etcd 1.1.1.2 --etcd 1.1.1.3 --etcd 1.1.1.4 \ 56 | --loadbalance 1.1.1.2 --loadbalance 1.1.1.2 --virturl-ip 1.1.2.2 \ 57 | --with-dashboard --with-heapster --with-promethus --with-EFK 58 | ``` 59 | output: 60 | ``` 61 | kubeinit serve on: 1.1.1.2:9527 62 | join master command: kubeinit join master 1.1.1.2:9527 sha:xxxxxx 63 | join node command: kubeinit join node 1.1.1.2:9527 sha:xxxxxx 64 | ``` 65 | 66 | > on other masters: 67 | ``` 68 | kubeinit join master 1.1.1.2:9527 sha:xxxxxx 69 | ``` 70 | 71 | > on other nodes: 72 | ``` 73 | kubeinit join node 1.1.1.2:9527 sha:xxxxxx 74 | ``` 75 | 76 | all this down, stop master0 kubeinit serve 77 | -------------------------------------------------------------------------------- /allinone.sh: -------------------------------------------------------------------------------- 1 | ./kubeinit gen --master 172.16.22.152 \ 2 | --etcd 172.16.22.152 \ 3 | --version 1.8.5 \ 4 | --loadbalance 172.16.22.152 5 | 6 | ./kubeinit apply -bie --passwd Fanux#123 7 | -------------------------------------------------------------------------------- /apply.sh: -------------------------------------------------------------------------------- 1 | ./kubeinit apply -bie --passwd Fanux#123 2 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | docker run --rm -v $GOPATH/src/github.com/fanux/kubeinit:/usr/local/go/src/github.com/fanux/kubeinit --workdir /usr/local/go/src/github.com/fanux/kubeinit golang:1.9 go build 2 | -------------------------------------------------------------------------------- /cmd/apply.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/fanux/kubeinit/define" 21 | "github.com/fanux/kubeinit/pkg" 22 | "github.com/spf13/cobra" 23 | ) 24 | 25 | // applyCmd represents the apply command 26 | var applyCmd = &cobra.Command{ 27 | Use: "apply", 28 | Short: "init env and appy kubeadmin init", 29 | Long: `初始化环境,拷贝bin程序,配置文件,加载镜像,执行kubeadm, 初始化其它节点 30 | init env, copy binarys config files, load docker images, exec kubeadm init and setup other master nodes`, 31 | Run: func(cmd *cobra.Command, args []string) { 32 | // TODO: Work your own magic here 33 | fmt.Println("appy called") 34 | pkg.Apply() 35 | }, 36 | } 37 | 38 | func init() { 39 | RootCmd.AddCommand(applyCmd) 40 | 41 | // Here you will define your flags and configuration settings. 42 | 43 | // Cobra supports Persistent Flags which will work for this command 44 | // and all subcommands, e.g.: 45 | // applyCmd.PersistentFlags().String("foo", "", "A help for foo") 46 | 47 | // Cobra supports local flags which will only run when this command 48 | // is called directly, e.g.: 49 | // applyCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 50 | applyCmd.Flags().BoolVarP(&define.InitBaseEnvironment, "init-base-env", "b", false, "init base environment, close firewalld selinux swap, copy bin and configs, load docker images") 51 | applyCmd.Flags().BoolVarP(&define.InitKubeadm, "init-kubeadm", "i", false, "exec kubeadm init") 52 | applyCmd.Flags().BoolVarP(&define.StartEtcdCluster, "start-etcd", "e", false, "docker compose up etcd compose files") 53 | 54 | applyCmd.Flags().BoolVarP(&define.Distribute, "distribute", "d", true, "distribute files to other masters and nodes") 55 | applyCmd.Flags().BoolVarP(&define.Pssh, "pssh", "p", true, "exec commands on other nodes, this flag needs other nodes passwords") 56 | 57 | applyCmd.Flags().StringVar(&define.Password, "passwd", "", "other nodes passwords") 58 | applyCmd.Flags().StringVar(&define.User, "user", "root", "use what use to exec shell commands") 59 | } 60 | -------------------------------------------------------------------------------- /cmd/clean.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | var cleanSh = ` 24 | kubeadm reset 25 | rm -rf /var/etcd 26 | rm -rf /var/lib/etcd 27 | rm -rf /data/etcd-data.etcd 28 | ` 29 | 30 | // cleanCmd represents the clean command 31 | var cleanCmd = &cobra.Command{ 32 | Use: "clean", 33 | Short: "A brief description of your command", 34 | Long: `A longer description that spans multiple lines and likely contains examples 35 | and usage of using your command. For example: 36 | 37 | Cobra is a CLI library for Go that empowers applications. 38 | This application is a tool to generate the needed files 39 | to quickly create a Cobra application.`, 40 | Run: func(cmd *cobra.Command, args []string) { 41 | // TODO: Work your own magic here 42 | fmt.Println("clean called") 43 | }, 44 | } 45 | 46 | func init() { 47 | RootCmd.AddCommand(cleanCmd) 48 | 49 | // Here you will define your flags and configuration settings. 50 | 51 | // Cobra supports Persistent Flags which will work for this command 52 | // and all subcommands, e.g.: 53 | // cleanCmd.PersistentFlags().String("foo", "", "A help for foo") 54 | 55 | // Cobra supports local flags which will only run when this command 56 | // is called directly, e.g.: 57 | // cleanCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 58 | 59 | } 60 | -------------------------------------------------------------------------------- /cmd/oninit.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | // oninitCmd represents the oninit command 24 | var oninitCmd = &cobra.Command{ 25 | Use: "oninit", 26 | Short: "online init, download bin, images, and exec kubeadm init etc... ,and save offline package", 27 | Long: ``, 28 | Run: func(cmd *cobra.Command, args []string) { 29 | // TODO: Work your own magic here 30 | fmt.Println("oninit called") 31 | }, 32 | } 33 | 34 | func init() { 35 | RootCmd.AddCommand(oninitCmd) 36 | 37 | // Here you will define your flags and configuration settings. 38 | 39 | // Cobra supports Persistent Flags which will work for this command 40 | // and all subcommands, e.g.: 41 | // oninitCmd.PersistentFlags().String("foo", "", "A help for foo") 42 | 43 | // Cobra supports local flags which will only run when this command 44 | // is called directly, e.g.: 45 | // oninitCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 46 | 47 | } 48 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/spf13/cobra" 22 | "github.com/spf13/viper" 23 | ) 24 | 25 | var cfgFile string 26 | 27 | // RootCmd represents the base command when called without any subcommands 28 | var RootCmd = &cobra.Command{ 29 | Use: "kubeinit", 30 | Short: "A brief description of your application", 31 | Long: `A longer description that spans multiple lines and likely contains 32 | examples and usage of using your application. For example: 33 | 34 | Cobra is a CLI library for Go that empowers applications. 35 | This application is a tool to generate the needed files 36 | to quickly create a Cobra application.`, 37 | // Uncomment the following line if your bare application 38 | // has an action associated with it: 39 | // Run: func(cmd *cobra.Command, args []string) { }, 40 | } 41 | 42 | // Execute adds all child commands to the root command sets flags appropriately. 43 | // This is called by main.main(). It only needs to happen once to the rootCmd. 44 | func Execute() { 45 | if err := RootCmd.Execute(); err != nil { 46 | fmt.Println(err) 47 | os.Exit(-1) 48 | } 49 | } 50 | 51 | func init() { 52 | cobra.OnInitialize(initConfig) 53 | 54 | // Here you will define your flags and configuration settings. 55 | // Cobra supports Persistent Flags, which, if defined here, 56 | // will be global for your application. 57 | 58 | RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.kubeinit.yaml)") 59 | // Cobra also supports local flags, which will only run 60 | // when this action is called directly. 61 | RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 62 | } 63 | 64 | // initConfig reads in config file and ENV variables if set. 65 | func initConfig() { 66 | if cfgFile != "" { // enable ability to specify config file via flag 67 | viper.SetConfigFile(cfgFile) 68 | } 69 | 70 | viper.SetConfigName(".kubeinit") // name of config file (without extension) 71 | viper.AddConfigPath("$HOME") // adding home directory as first search path 72 | viper.AutomaticEnv() // read in environment variables that match 73 | 74 | // If a config file is found, read it in. 75 | if err := viper.ReadInConfig(); err == nil { 76 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | apiVersion: kubeadm.k8s.io/v1alpha1 2 | kind: MasterConfiguration 3 | apiServerCertSANs: 4 | - 172.31.244.231 5 | - 172.31.244.232 6 | - 172.31.244.233 7 | - 172.31.244.234 8 | - master1 9 | - master2 10 | - master3 11 | - node1 12 | - 47.75.1.72 13 | 14 | etcd: 15 | endpoints: 16 | - http://172.31.244.232:2379 17 | 18 | apiServerExtraArgs: 19 | endpoint-reconciler-type: lease 20 | 21 | networking: 22 | podSubnet: 192.168.0.0/16 23 | kubernetesVersion: v1.9.1 24 | -------------------------------------------------------------------------------- /define/define.go: -------------------------------------------------------------------------------- 1 | package define 2 | 3 | //EtcdComposeTempST is 4 | type EtcdComposeTempST struct { 5 | Index string 6 | Image string 7 | EndPoint string 8 | EndPoints string 9 | } 10 | 11 | //HaproxyTemp is 12 | var HaproxyTemp = `global 13 | daemon 14 | log 127.0.0.1 local0 15 | log 127.0.0.1 local1 notice 16 | maxconn 4096 17 | 18 | defaults 19 | log global 20 | retries 3 21 | maxconn 2000 22 | timeout connect 5s 23 | timeout client 50s 24 | timeout server 50s 25 | 26 | frontend k8s 27 | bind *:{{.LoadbalancePort}} 28 | mode tcp 29 | default_backend k8s-backend 30 | 31 | backend k8s-backend 32 | balance roundrobin 33 | mode tcp 34 | {{range $index, $element := .BackendEndPoint}} server k8s-{{$index}} {{$element}}:6443 check {{"\n"}}{{end}} 35 | ` 36 | 37 | //HaproxyTempST is 38 | type HaproxyTempST struct { 39 | LoadbalancePort string 40 | BackendEndPoint []string 41 | } 42 | 43 | //Flags is 44 | type Flags struct { 45 | MasterIPs []string 46 | NodeIPs []string 47 | OtherAPIServerCertSANs []string 48 | EtcdIPs []string 49 | MasterEndPoints []string 50 | APIServerCertSANs []string 51 | PodSubnet string 52 | KubernetesVersion string 53 | LoadbalancePort string 54 | LoadbalanceIP string 55 | Apply bool 56 | EtcdImage string 57 | Version string 58 | Subnet string 59 | 60 | // render out compose file and kubeadm config 61 | ConfigOutDir string 62 | // /etc/kubernetes files, this need copy to other nodes, and change ips 63 | KubernetesDir string 64 | 65 | //download kube bin url 66 | DownloadURL string 67 | } 68 | 69 | //KubeFlags is 70 | var ( 71 | KubeFlags Flags 72 | 73 | InitBaseEnvironment bool 74 | InitKubeadm bool 75 | InitOtherMasters bool 76 | StartEtcdCluster bool 77 | Distribute bool 78 | Pssh bool 79 | User string 80 | Password string 81 | ) 82 | -------------------------------------------------------------------------------- /define/logo.go: -------------------------------------------------------------------------------- 1 | package define 2 | 3 | //LOGO is 4 | var LOGO = ` 5 | *************************** Welcom to use kubeinit *************************** 6 | __ __ _ _ __ 7 | / /____ __/ /_ ___ (_)___ (_) /_ 8 | / //_/ / / / __ \/ _ \/ / __ \/ / __/ 9 | / ,< / /_/ / /_/ / __/ / / / / / /_ 10 | /_/|_|\__,_/_.___/\___/_/_/ /_/_/\__/ 11 | 12 | 13 | Author : fanux 14 | QQ group : 98488045 15 | Email : fhtjob@hotmail.com 16 | Home page : www.lameleg.com 17 | 18 | ****************************************************************************** 19 | ` 20 | -------------------------------------------------------------------------------- /docs/cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fanux/kubeinit/0263b0b097a21a3b05a902dd3a2c5556e8ab0e8b/docs/cluster.png -------------------------------------------------------------------------------- /install-online.sh: -------------------------------------------------------------------------------- 1 | yum install -y git 2 | yum install -y docker 3 | cat < /etc/yum.repos.d/kubernetes.repo 4 | [kubernetes] 5 | name=Kubernetes 6 | baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 7 | enabled=1 8 | gpgcheck=1 9 | repo_gpgcheck=1 10 | gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg 11 | EOF 12 | setenforce 0 13 | yum install -y kubelet kubeadm kubectl 14 | systemctl enable kubelet && systemctl start kubelet 15 | cat < /etc/sysctl.d/k8s.conf 16 | net.bridge.bridge-nf-call-ip6tables = 1 17 | net.bridge.bridge-nf-call-iptables = 1 18 | EOF 19 | sysctl --system 20 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/fanux/kubeinit/cmd" 21 | ) 22 | 23 | var showCluster = ` cluster overview > 24 | kubectl dashboard 25 | | 26 | V 27 | +------------------------+ join 28 | | LB 10.1.245.94 haproxy| <--- Nodes 29 | +------------------------+ 30 | | 31 | |--master1 manager1 schedule1 10.1.245.93 32 | |--master2 manager2 schedule2 10.1.245.95 =============> etcd cluster http://10.1.245.93:2379,http://10.1.245.94:2379,http://10.1.245.95:2379 33 | +--master3 manager3 schedule3 10.1.245.94 34 | 35 | 36 | +---------------------------------+ 37 | | qq群:98488045 | 38 | | phone NO. 15357921248 | 39 | | Email: lamelegdog@gmail.com | 40 | +---------------------------------+ 41 | ` 42 | 43 | func main() { 44 | fmt.Println(showCluster) 45 | cmd.Execute() 46 | } 47 | -------------------------------------------------------------------------------- /out/10-kubeadm.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" 3 | Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true" 4 | Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin" 5 | Environment="KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10 --cluster-domain=cluster.local" 6 | Environment="KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt" 7 | Environment="KUBELET_CADVISOR_ARGS=--cadvisor-port=0" 8 | Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs" 9 | Environment="KUBELET_CERTIFICATE_ARGS=--rotate-certificates=true --cert-dir=/var/lib/kubelet/pki" 10 | ExecStart= 11 | ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CADVISOR_ARGS $KUBELET_CGROUP_ARGS $KUBELET_CERTIFICATE_ARGS $KUBELET_EXTRA_ARGS 12 | -------------------------------------------------------------------------------- /out/calicoctl.yaml: -------------------------------------------------------------------------------- 1 | # Calico Version v2.6.3 2 | # https://docs.projectcalico.org/v2.6/releases#v2.6.3 3 | # This manifest includes the following component versions: 4 | # calico/ctl:v1.6.2 5 | 6 | apiVersion: v1 7 | kind: Pod 8 | metadata: 9 | name: calicoctl 10 | namespace: kube-system 11 | spec: 12 | hostNetwork: true 13 | containers: 14 | - name: calicoctl 15 | image: quay.io/calico/ctl:v1.6.2 16 | command: ["/bin/sh", "-c", "while true; do sleep 3600; done"] 17 | env: 18 | - name: ETCD_ENDPOINTS 19 | valueFrom: 20 | configMapKeyRef: 21 | name: calico-config 22 | key: etcd_endpoints 23 | -------------------------------------------------------------------------------- /out/dashboard-admin.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1beta1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: kubernetes-dashboard 5 | labels: 6 | k8s-app: kubernetes-dashboard 7 | roleRef: 8 | apiGroup: rbac.authorization.k8s.io 9 | kind: ClusterRole 10 | name: cluster-admin 11 | subjects: 12 | - kind: ServiceAccount 13 | name: kubernetes-dashboard 14 | namespace: kube-system 15 | -------------------------------------------------------------------------------- /out/deploy/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | 3 | COPY heapster eventer / 4 | COPY ca-certificates.crt /etc/ssl/certs/ 5 | 6 | # nobody:nobody 7 | USER 65534:65534 8 | ENTRYPOINT ["/heapster"] 9 | -------------------------------------------------------------------------------- /out/deploy/kube-config/google/heapster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: heapster 5 | namespace: kube-system 6 | --- 7 | apiVersion: extensions/v1beta1 8 | kind: Deployment 9 | metadata: 10 | name: heapster 11 | namespace: kube-system 12 | spec: 13 | replicas: 1 14 | template: 15 | metadata: 16 | labels: 17 | task: monitoring 18 | k8s-app: heapster 19 | spec: 20 | serviceAccountName: heapster 21 | containers: 22 | - name: heapster 23 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 24 | imagePullPolicy: IfNotPresent 25 | command: 26 | - /heapster 27 | - --source=kubernetes:https://kubernetes.default 28 | - --sink=gcm 29 | - --sink=gcl 30 | - --poll_duration=2m 31 | - --stats_resolution=1m 32 | volumeMounts: 33 | - mountPath: /etc/ssl/certs 34 | name: ssl-certs 35 | readOnly: true 36 | volumes: 37 | - name: ssl-certs 38 | hostPath: 39 | path: /etc/ssl/certs 40 | --- 41 | apiVersion: v1 42 | kind: Service 43 | metadata: 44 | labels: 45 | task: monitoring 46 | # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) 47 | # If you are NOT using this as an addon, you should comment out this line. 48 | kubernetes.io/cluster-service: 'true' 49 | kubernetes.io/name: Heapster 50 | name: heapster 51 | namespace: kube-system 52 | spec: 53 | ports: 54 | - port: 80 55 | targetPort: 8082 56 | selector: 57 | k8s-app: heapster 58 | -------------------------------------------------------------------------------- /out/deploy/kube-config/influxdb/grafana.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: monitoring-grafana 5 | namespace: kube-system 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | task: monitoring 12 | k8s-app: grafana 13 | spec: 14 | containers: 15 | - name: grafana 16 | image: gcr.io/google_containers/heapster-grafana-amd64:v4.4.3 17 | ports: 18 | - containerPort: 3000 19 | protocol: TCP 20 | volumeMounts: 21 | - mountPath: /etc/ssl/certs 22 | name: ca-certificates 23 | readOnly: true 24 | - mountPath: /var 25 | name: grafana-storage 26 | env: 27 | - name: INFLUXDB_HOST 28 | value: monitoring-influxdb 29 | - name: GF_SERVER_HTTP_PORT 30 | value: "3000" 31 | # The following env variables are required to make Grafana accessible via 32 | # the kubernetes api-server proxy. On production clusters, we recommend 33 | # removing these env variables, setup auth for grafana, and expose the grafana 34 | # service using a LoadBalancer or a public IP. 35 | - name: GF_AUTH_BASIC_ENABLED 36 | value: "false" 37 | - name: GF_AUTH_ANONYMOUS_ENABLED 38 | value: "true" 39 | - name: GF_AUTH_ANONYMOUS_ORG_ROLE 40 | value: Admin 41 | - name: GF_SERVER_ROOT_URL 42 | # If you're only using the API Server proxy, set this value instead: 43 | # value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy 44 | value: / 45 | volumes: 46 | - name: ca-certificates 47 | hostPath: 48 | path: /etc/ssl/certs 49 | - name: grafana-storage 50 | emptyDir: {} 51 | --- 52 | apiVersion: v1 53 | kind: Service 54 | metadata: 55 | labels: 56 | # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) 57 | # If you are NOT using this as an addon, you should comment out this line. 58 | kubernetes.io/cluster-service: 'true' 59 | kubernetes.io/name: monitoring-grafana 60 | name: monitoring-grafana 61 | namespace: kube-system 62 | spec: 63 | # In a production setup, we recommend accessing Grafana through an external Loadbalancer 64 | # or through a public IP. 65 | # type: LoadBalancer 66 | # You could also use NodePort to expose the service at a randomly-generated port 67 | # type: NodePort 68 | ports: 69 | - port: 80 70 | targetPort: 3000 71 | selector: 72 | k8s-app: grafana 73 | -------------------------------------------------------------------------------- /out/deploy/kube-config/influxdb/heapster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: heapster 5 | namespace: kube-system 6 | --- 7 | apiVersion: extensions/v1beta1 8 | kind: Deployment 9 | metadata: 10 | name: heapster 11 | namespace: kube-system 12 | spec: 13 | replicas: 1 14 | template: 15 | metadata: 16 | labels: 17 | task: monitoring 18 | k8s-app: heapster 19 | spec: 20 | serviceAccountName: heapster 21 | containers: 22 | - name: heapster 23 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 24 | imagePullPolicy: IfNotPresent 25 | command: 26 | - /heapster 27 | - --source=kubernetes:https://kubernetes.default 28 | - --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086 29 | --- 30 | apiVersion: v1 31 | kind: Service 32 | metadata: 33 | labels: 34 | task: monitoring 35 | # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) 36 | # If you are NOT using this as an addon, you should comment out this line. 37 | kubernetes.io/cluster-service: 'true' 38 | kubernetes.io/name: Heapster 39 | name: heapster 40 | namespace: kube-system 41 | spec: 42 | ports: 43 | - port: 80 44 | targetPort: 8082 45 | selector: 46 | k8s-app: heapster 47 | -------------------------------------------------------------------------------- /out/deploy/kube-config/influxdb/influxdb.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: monitoring-influxdb 5 | namespace: kube-system 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | task: monitoring 12 | k8s-app: influxdb 13 | spec: 14 | containers: 15 | - name: influxdb 16 | image: gcr.io/google_containers/heapster-influxdb-amd64:v1.3.3 17 | volumeMounts: 18 | - mountPath: /data 19 | name: influxdb-storage 20 | volumes: 21 | - name: influxdb-storage 22 | emptyDir: {} 23 | --- 24 | apiVersion: v1 25 | kind: Service 26 | metadata: 27 | labels: 28 | task: monitoring 29 | # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) 30 | # If you are NOT using this as an addon, you should comment out this line. 31 | kubernetes.io/cluster-service: 'true' 32 | kubernetes.io/name: monitoring-influxdb 33 | name: monitoring-influxdb 34 | namespace: kube-system 35 | spec: 36 | ports: 37 | - port: 8086 38 | targetPort: 8086 39 | selector: 40 | k8s-app: influxdb 41 | -------------------------------------------------------------------------------- /out/deploy/kube-config/rbac/heapster-rbac.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1beta1 3 | metadata: 4 | name: heapster 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: system:heapster 9 | subjects: 10 | - kind: ServiceAccount 11 | name: heapster 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-test/heapster-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | labels: 5 | k8s-app: heapster-test 6 | name: heapster 7 | name: heapster 8 | namespace: heapster-e2e-tests 9 | spec: 10 | replicas: 1 11 | selector: 12 | k8s-app: heapster-test 13 | template: 14 | metadata: 15 | labels: 16 | k8s-app: heapster-test 17 | spec: 18 | containers: 19 | - name: heapster-test 20 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 21 | imagePullPolicy: Always 22 | command: 23 | - /heapster 24 | - --source=kubernetes.summary_api:'' 25 | - --sink=log 26 | volumeMounts: 27 | - name: ssl-certs 28 | mountPath: /etc/ssl/certs 29 | readOnly: true 30 | volumes: 31 | - name: ssl-certs 32 | hostPath: 33 | path: /etc/ssl/certs 34 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-test/heapster-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: heapster 5 | namespace: heapster-e2e-tests 6 | spec: 7 | ports: 8 | - port: 80 9 | targetPort: 8082 10 | selector: 11 | k8s-app: heapster-test 12 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-test/heapster-summary-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | labels: 5 | k8s-app: heapster-test 6 | name: heapster 7 | name: heapster 8 | namespace: heapster-e2e-tests 9 | spec: 10 | replicas: 1 11 | selector: 12 | k8s-app: heapster-test 13 | template: 14 | metadata: 15 | labels: 16 | k8s-app: heapster-test 17 | spec: 18 | containers: 19 | - name: heapster-test 20 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 21 | imagePullPolicy: Always 22 | command: 23 | - /heapster 24 | - --source=kubernetes.summary_api:https://kubernetes.default 25 | - --sink=log 26 | volumeMounts: 27 | - name: ssl-certs 28 | mountPath: /etc/ssl/certs 29 | readOnly: true 30 | - name: eventer-test 31 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 32 | imagePullPolicy: Always 33 | command: 34 | - /eventer 35 | - --source=kubernetes:https://kubernetes.default 36 | - --sink=log 37 | volumeMounts: 38 | - name: ssl-certs 39 | mountPath: /etc/ssl/certs 40 | readOnly: true 41 | volumes: 42 | - name: ssl-certs 43 | hostPath: 44 | path: /etc/ssl/certs 45 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-with-apiserver/heapster-apiserver-secrets.template: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: heapster-apiserver-secrets 5 | labels: 6 | k8s-app: heapster 7 | type: Opaque 8 | data: 9 | known-tokens.csv: {{.HEAPSTER_API_KNOWN_TOKENS_BASE64}} 10 | basic-auth.csv: {{.HEAPSTER_API_BASIC_AUTH_BASE64}} 11 | ca.crt: {{.HEAPSTER_APISERVER_CA_CERT_BASE64}} 12 | server.cert: {{.HEAPSTER_APISERVER_CERT_BASE64}} 13 | server.key: {{.HEAPSTER_APISERVER_KEY_BASE64}} 14 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-with-apiserver/heapster-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: heapster-apiserver 5 | namespace: kube-system 6 | labels: 7 | k8s-app: heapster 8 | module: apiserver 9 | version: v6 10 | spec: 11 | selector: 12 | matchLabels: 13 | k8s-app: heapster 14 | module: apiserver 15 | version: v6 16 | template: 17 | metadata: 18 | name: heapster 19 | labels: 20 | k8s-app: heapster 21 | module: apiserver 22 | version: v6 23 | spec: 24 | containers: 25 | - name: heapster 26 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 27 | command: 28 | - /heapster 29 | - --source=kubernetes.summary_api:'' 30 | - --api-server 31 | - --service-cluster-ip-range=10.10.0.0/24 32 | - --secure-port=6443 33 | - --basic-auth-file=/srv/kubernetes/basic-auth.csv 34 | - --token-auth-file=/srv/kubernetes/known-tokens.csv 35 | - --client-ca-file=/srv/kubernetes/ca.crt 36 | - --tls-cert-file=/srv/kubernetes/server.cert 37 | - --tls-private-key-file=/srv/kubernetes/server.key 38 | ports: 39 | - containerPort: 6443 40 | name: https 41 | - containerPort: 8080 42 | name: http 43 | volumeMounts: 44 | - name: heapster-apiserver-secrets 45 | mountPath: /srv/kubernetes/ 46 | readOnly: true 47 | - name: ssl-certs 48 | mountPath: /etc/ssl/certs 49 | readOnly: true 50 | volumes: 51 | - name: heapster-apiserver-secrets 52 | secret: 53 | secretName: heapster-apiserver-secrets 54 | - name: ssl-certs 55 | hostPath: 56 | path: /etc/ssl/certs 57 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone-with-apiserver/heapster-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: heapster-apiserver 5 | namespace: kube-system 6 | labels: 7 | kubernetes.io/name: "Heapster-apiserver" 8 | spec: 9 | type: LoadBalancer 10 | selector: 11 | k8s-app: heapster 12 | module: apiserver 13 | ports: 14 | - name: http 15 | port: 80 16 | targetPort: 8082 17 | - name: https 18 | port: 443 19 | targetPort: 6443 20 | -------------------------------------------------------------------------------- /out/deploy/kube-config/standalone/heapster-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: heapster 5 | namespace: kube-system 6 | --- 7 | apiVersion: extensions/v1beta1 8 | kind: Deployment 9 | metadata: 10 | name: heapster 11 | namespace: kube-system 12 | spec: 13 | replicas: 1 14 | template: 15 | metadata: 16 | labels: 17 | task: monitoring 18 | k8s-app: heapster 19 | spec: 20 | serviceAccountName: heapster 21 | containers: 22 | - name: heapster 23 | image: gcr.io/google_containers/heapster-amd64:v1.4.2 24 | imagePullPolicy: IfNotPresent 25 | command: 26 | - /heapster 27 | - --source=kubernetes:https://kubernetes.default 28 | --- 29 | apiVersion: v1 30 | kind: Service 31 | metadata: 32 | labels: 33 | task: monitoring 34 | # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons) 35 | # If you are NOT using this as an addon, you should comment out this line. 36 | kubernetes.io/cluster-service: 'true' 37 | kubernetes.io/name: Heapster 38 | name: heapster 39 | namespace: kube-system 40 | spec: 41 | ports: 42 | - port: 80 43 | targetPort: 8082 44 | selector: 45 | k8s-app: heapster 46 | -------------------------------------------------------------------------------- /out/deploy/kube.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/kube-config/influxdb" 4 | 5 | start() { 6 | if kubectl apply -f "$DIR/" &> /dev/null; then 7 | echo "heapster pods have been setup" 8 | else 9 | echo "failed to setup heapster pods" 10 | fi 11 | } 12 | 13 | stop() { 14 | echo -n "heapster resources being removed..." 15 | kubectl --namespace kube-system delete svc,deployment,rc,rs -l task=monitoring &> /dev/null 16 | # wait for the pods to disappear. 17 | while kubectl --namespace kube-system get pods -l "task=monitoring" -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep -c . &> /dev/null; do 18 | echo -n "." 19 | sleep 2 20 | done 21 | echo 22 | echo "heapster pods have all been removed." 23 | } 24 | 25 | case "$1" in 26 | start) 27 | start 28 | ;; 29 | stop) 30 | stop 31 | ;; 32 | restart) 33 | stop 34 | start 35 | ;; 36 | *) 37 | echo "Usage: $0 {start|stop|restart}" 38 | ;; 39 | esac 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /out/etcd-docker-compose-0.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | etcd0: 4 | container_name: etcd_infra0 5 | image: gcr.io/google_containers/etcd-amd64:3.1.11 6 | command: | 7 | etcd --name infra0 8 | 9 | --initial-advertise-peer-urls http://192.168.11.16:2380 10 | --listen-peer-urls http://192.168.11.16:2380 11 | --listen-client-urls http://192.168.11.16:2379,http://127.0.0.1:2379 12 | --advertise-client-urls http://192.168.11.16:2379 13 | --data-dir /etcd-data.etcd 14 | --initial-cluster-token etcd-cluster-1 15 | --initial-cluster infra0=http://192.168.11.16:2380,infra1=http://192.168.111.44:2380,infra2=http://192.168.111.50:2380 16 | --initial-cluster-state new 17 | restart: always 18 | volumes: 19 | - /data/etcd-data.etcd:/etcd-data.etcd 20 | network_mode: "host" 21 | 22 | -------------------------------------------------------------------------------- /out/etcd-docker-compose-1.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | etcd1: 4 | container_name: etcd_infra1 5 | image: gcr.io/google_containers/etcd-amd64:3.1.11 6 | command: | 7 | etcd --name infra1 8 | --initial-advertise-peer-urls http://192.168.111.44:2380 9 | --listen-peer-urls http://192.168.111.44:2380 10 | --listen-client-urls http://192.168.111.44:2379,http://127.0.0.1:2379 11 | --advertise-client-urls http://192.168.111.44:2379 12 | --data-dir /etcd-data.etcd 13 | --initial-cluster-token etcd-cluster-1 14 | --initial-cluster infra0=http://192.168.11.16:2380,infra1=http://192.168.111.44:2380,infra2=http://192.168.111.50:2380 15 | --initial-cluster-state new 16 | restart: always 17 | volumes: 18 | - /data/etcd-data.etcd:/etcd-data.etcd 19 | network_mode: "host" 20 | 21 | -------------------------------------------------------------------------------- /out/etcd-docker-compose-2.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | etcd2: 4 | container_name: etcd_infra2 5 | image: gcr.io/google_containers/etcd-amd64:3.1.11 6 | command: | 7 | etcd --name infra2 8 | --initial-advertise-peer-urls http://192.168.111.50:2380 9 | --listen-peer-urls http://192.168.111.50:2380 10 | --listen-client-urls http://192.168.111.50:2379,http://127.0.0.1:2379 11 | --advertise-client-urls http://192.168.111.50:2379 12 | --data-dir /etcd-data.etcd 13 | --initial-cluster-token etcd-cluster-1 14 | --initial-cluster infra0=http://192.168.11.16:2380,infra1=http://192.168.111.44:2380,infra2=http://192.168.111.50:2380 15 | --initial-cluster-state new 16 | restart: always 17 | volumes: 18 | - /data/etcd-data.etcd:/etcd-data.etcd 19 | network_mode: "host" 20 | 21 | -------------------------------------------------------------------------------- /out/haproxy.cfg: -------------------------------------------------------------------------------- 1 | global 2 | daemon 3 | log 127.0.0.1 local0 4 | log 127.0.0.1 local1 notice 5 | maxconn 4096 6 | 7 | defaults 8 | log global 9 | retries 3 10 | maxconn 2000 11 | timeout connect 5s 12 | timeout client 50s 13 | timeout server 50s 14 | 15 | frontend k8s 16 | bind *:6444 17 | mode tcp 18 | default_backend k8s-backend 19 | 20 | backend k8s-backend 21 | balance roundrobin 22 | mode tcp 23 | <<<<<<< HEAD 24 | server k8s-0 172.21.161.28:6443 check 25 | server k8s-1 172.21.161.29:6443 check 26 | server k8s-2 172.21.161.30:6443 check 27 | ======= 28 | server k8s-0 192.168.11.16:6443 check 29 | server k8s-1 192.168.111.44:6443 check 30 | server k8s-2 192.168.111.50:6443 check 31 | >>>>>>> v2.0 32 | 33 | -------------------------------------------------------------------------------- /out/kubeadm.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kubeadm.k8s.io/v1alpha1 2 | kind: MasterConfiguration 3 | apiServerCertSANs: 4 | 5 | - 192.168.11.16 6 | - 192.168.111.44 7 | - 192.168.111.50 8 | - 10.1.245.93 9 | 10 | etcd: 11 | endpoints: 12 | - http://192.168.11.16:2379 13 | - http://192.168.111.44:2379 14 | - http://192.168.111.50:2379 15 | 16 | networking: 17 | podSubnet: 10.122.0.0/16 18 | kubernetesVersion: v1.9.2 19 | -------------------------------------------------------------------------------- /out/kubeinit.json: -------------------------------------------------------------------------------- 1 | {"MasterIPs":["192.168.11.16","192.168.111.44","192.168.111.50"],"NodeIPs":[],"OtherAPIServerCertSANs":[],"EtcdIPs":["192.168.11.16","192.168.111.44","192.168.111.50"],"MasterEndPoints":null,"APIServerCertSANs":null,"PodSubnet":"","KubernetesVersion":"","LoadbalancePort":"6444","LoadbalanceIP":"10.1.245.93","Apply":false,"EtcdImage":"gcr.io/google_containers/etcd-amd64:3.1.11","Version":"v1.9.2","Subnet":"10.122.0.0/16","ConfigOutDir":"","KubernetesDir":""} 2 | -------------------------------------------------------------------------------- /out/kubelet.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=kubelet: The Kubernetes Node Agent 3 | Documentation=http://kubernetes.io/docs/ 4 | 5 | [Service] 6 | ExecStart=/usr/bin/kubelet 7 | Restart=always 8 | StartLimitInterval=0 9 | RestartSec=10 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /pkg/dashboard/manifast.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fanux/kubeinit/0263b0b097a21a3b05a902dd3a2c5556e8ab0e8b/pkg/dashboard/manifast.go -------------------------------------------------------------------------------- /pkg/dashboard/run.go: -------------------------------------------------------------------------------- 1 | package dashboard 2 | 3 | //Dashboard is 4 | type Dashboard struct { 5 | } 6 | 7 | //Info is 8 | func (e *Dashboard) Info() string { 9 | } 10 | 11 | //Gen is 12 | func (e *Dashboard) Gen() error { 13 | } 14 | 15 | //Run is 16 | func (e *Dashboard) Run() error { 17 | } 18 | 19 | //Clean is 20 | func (e *Dashboard) Clean() error { 21 | } 22 | -------------------------------------------------------------------------------- /pkg/etcd/manifast.go: -------------------------------------------------------------------------------- 1 | package etcd 2 | 3 | //EtcdComposeTemp is 4 | var EtcdComposeTemp = `version: '2.1' 5 | services: 6 | etcd{{.Index}}: 7 | container_name: etcd_infra{{.Index}} 8 | image: {{.Image}} 9 | command: | 10 | etcd --name infra{{.Index}} 11 | --initial-advertise-peer-urls http://{{.EndPoint}}:2380 12 | --listen-peer-urls http://{{.EndPoint}}:2380 13 | --listen-client-urls http://{{.EndPoint}}:2379,http://127.0.0.1:2379 14 | --advertise-client-urls http://{{.EndPoint}}:2379 15 | --data-dir /etcd-data.etcd 16 | --initial-cluster-token etcd-cluster-1 17 | --initial-cluster {{.EndPoints}} 18 | --initial-cluster-state new 19 | restart: always 20 | volumes: 21 | - /data/etcd-data.etcd:/etcd-data.etcd 22 | network_mode: "host" 23 | 24 | ` 25 | 26 | //ComposeTempST is 27 | type ComposeTempST struct { 28 | Index string 29 | Image string 30 | EndPoint string 31 | EndPoints string 32 | } 33 | -------------------------------------------------------------------------------- /pkg/etcd/run.go: -------------------------------------------------------------------------------- 1 | package etcd 2 | 3 | import ( 4 | "fmt" 5 | "html/template" 6 | "strconv" 7 | 8 | "github.com/fanux/kubeinit/define" 9 | "github.com/fanux/kubeinit/pkg" 10 | ) 11 | 12 | //Etcd is 13 | type Etcd struct { 14 | tp ComposeTempST 15 | } 16 | 17 | //Info is 18 | func (e *Etcd) Info() (string, string) { 19 | return "etcd", nil 20 | } 21 | 22 | //Gen is 23 | func (e *Etcd) Gen() error { 24 | genEtcdyamls(define.KubeFlags.EtcdIPs, EtcdComposeTemp) 25 | return nil 26 | } 27 | 28 | //Run is 29 | func (e *Etcd) Run() error { 30 | //TODO 31 | return nil 32 | } 33 | 34 | //Clean is 35 | func (e *Etcd) Clean() error { 36 | //TODO 37 | return nil 38 | } 39 | 40 | // infra0=http://10.1.245.93:2380,infra1=http://10.1.245.94:2380,infra2=http://10.1.245.95:2380 41 | func getEtcdEndpoints(etcdIPs []string) (out string) { 42 | for i, ip := range etcdIPs { 43 | var temp string 44 | temp = fmt.Sprintf("infra%d=http://%s:2380,", i, ip) 45 | out = out + temp 46 | } 47 | 48 | out = out[:len(out)-1] 49 | 50 | fmt.Println("etcd endpoints: ", out) 51 | return 52 | } 53 | 54 | func genEtcdyamls(etcdIPs []string, tp string) { 55 | var etcdComposeFileNmae string 56 | 57 | etcd := define.ComposeTempST{} 58 | etcd.EndPoints = getEtcdEndpoints(etcdIPs) 59 | etcd.Image = define.KubeFlags.EtcdImage 60 | 61 | for i, ip := range etcdIPs { 62 | etcd.EndPoint = ip 63 | etcd.Index = strconv.Itoa(i) 64 | 65 | etcdComposeFileNmae = fmt.Sprintf("%s/etcd-docker-compose-%d.yml", outDir, ip) 66 | t := template.New("etcd") 67 | 68 | pkg.Render(t, tp, etcd, etcdComposeFileNmae) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /pkg/ha/manifast.go: -------------------------------------------------------------------------------- 1 | package ha 2 | 3 | var keepalived = ` 4 | vrrp_sync_group VG1 { 5 | group { 6 | VI_1 7 | VI_2 8 | } 9 | } 10 | 11 | vrrp_instance VI_1 { 12 | state MASTER 13 | interface eth0 14 | virtual_router_id 51 15 | priority 100 16 | advert_int 1 17 | authentication { 18 | auth_type PASS 19 | auth_pass 1111 20 | } 21 | virtual_ipaddress { 22 | 10.23.8.80 23 | } 24 | } 25 | 26 | vrrp_instance VI_2 { 27 | state MASTER 28 | interface eth1 29 | virtual_router_id 51 30 | priority 100 31 | advert_int 1 32 | authentication { 33 | auth_type PASS 34 | auth_pass 1111 35 | } 36 | virtual_ipaddress { 37 | 172.18.1.254 38 | } 39 | } 40 | 41 | virtual_server 10.23.8.80 80 { 42 | delay_loop 6 43 | lb_algo wlc 44 | lb_kind NAT 45 | persistence_timeout 600 46 | protocol TCP 47 | 48 | real_server 172.18.1.11 80 { 49 | weight 100 50 | TCP_CHECK { 51 | connect_timeout 3 52 | } 53 | } 54 | real_server 172.18.1.12 80 { 55 | weight 100 56 | TCP_CHECK { 57 | connect_timeout 3 58 | } 59 | } 60 | real_server 172.18.1.13 80 { 61 | weight 100 62 | TCP_CHECK { 63 | connect_timeout 3 64 | } 65 | } 66 | } 67 | ` 68 | -------------------------------------------------------------------------------- /pkg/ha/run.go: -------------------------------------------------------------------------------- 1 | package ha 2 | 3 | //Ha is 4 | type Ha struct{} 5 | 6 | //Info is 7 | func (e *Ha) Info() (string, string) { 8 | return "ha", nil 9 | } 10 | 11 | //Gen is 12 | func (e *Ha) Gen() error { 13 | return nil 14 | } 15 | 16 | //Run is 17 | func (e *Ha) Run() error { 18 | return nil 19 | } 20 | 21 | //Clean is 22 | func (e *Ha) Clean() error { 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /pkg/initer.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | //Initer is a interface to define modules to install 4 | type Initer interface { 5 | //query module name 6 | Info() (string, string) 7 | //generate and render config files 8 | Gen() error 9 | //install module 10 | Run() error 11 | //clean module 12 | Clean() error 13 | //install offline 14 | InstallOffline() error 15 | //Install online 16 | InstallOnline() error 17 | //Save image, config file or bin 18 | Save() error 19 | } 20 | -------------------------------------------------------------------------------- /pkg/kubecore/kubecore.go: -------------------------------------------------------------------------------- 1 | package kubecore 2 | 3 | import ( 4 | "fmt" 5 | "html/template" 6 | "os/exec" 7 | "strings" 8 | 9 | "github.com/fanux/kubeinit/pkg" 10 | ) 11 | 12 | //Kubecore is 13 | type Kubecore struct{} 14 | 15 | //Info is 16 | func (e *Kubecore) Info() (string, string) { 17 | return "kubecore", "kubecore include kubelet, apiserver manager scheduler and kubeproxy" 18 | } 19 | 20 | func genKubeAdmConfigFile(etcdIPs []string, masterIPs []string, loadbalanceIP string, loadbalancePort string, subnet string, version string, tp string) { 21 | kubeadm := define.KubeadmTempST{} 22 | if stringsIn(masterIPs, loadbalanceIP) { 23 | kubeadm.APIServerCertSANs = masterIPs 24 | } else { 25 | kubeadm.APIServerCertSANs = append(masterIPs, loadbalanceIP) 26 | } 27 | //add other cert sans ips to APIServerCertSANs list 28 | for _, ip := range define.KubeFlags.OtherAPIServerCertSANs { 29 | if stringsIn(kubeadm.APIServerCertSANs, ip) { 30 | } else { 31 | kubeadm.APIServerCertSANs = append(kubeadm.APIServerCertSANs, ip) 32 | } 33 | } 34 | kubeadm.EtcdEndPoints = etcdIPs 35 | kubeadm.PodSubnet = subnet 36 | kubeadm.KubernetesVersion = version 37 | 38 | t := template.New("kubeadmConfig") 39 | pkg.Render(t, tp, kubeadm, "out/kube/kubeadm.yaml") 40 | } 41 | 42 | func genKubeletSystemdConfig(tp string) { 43 | driver := "cgroupfs" 44 | out, err := exec.Command("docker", "info").Output() 45 | outstr := string(out) 46 | if err != nil { 47 | fmt.Println("run docker info error: ", err) 48 | } 49 | if strings.Contains(outstr, "cgroupfs") { 50 | } else if strings.Contains(outstr, "systemd") { 51 | driver = "systemd" 52 | } 53 | 54 | t := template.New("systemdConfig") 55 | pkg.Render(t, tp, driver, "out/kube/10-kubeadm.conf") 56 | } 57 | 58 | //Gen is generate kubeadm kubelet config files 59 | func (e *Kubecore) Gen() error { 60 | //gen kubeadm config file 61 | genKubeAdmConfigFile(define.KubeFlags.EtcdIPs, define.KubeFlags.MasterIPs, define.KubeFlags.LoadbalanceIP, 62 | define.KubeFlags.LoadbalancePort, define.KubeFlags.Subnet, define.KubeFlags.Version, define.KubeadmTemp) 63 | 64 | //gen kubelet config file 65 | genKubeletSystemdConfig(KubeletSystemdTemp) 66 | pkg.WriteFile("out/kube/kubelet.service", KubeletServiceStr) 67 | return nil 68 | } 69 | 70 | //Run is 71 | func (e *Kubecore) Run() error { 72 | str := ApplyShellOutput(runSh) 73 | fmt.Println(str) 74 | //TODO fetch join command 75 | return nil 76 | } 77 | 78 | //Clean is 79 | func (e *Kubecore) Clean() error { 80 | //TODO 81 | return nil 82 | } 83 | 84 | //InstallOffline is 85 | func (e *Kubecore) InstallOffline() error { 86 | str := ApplyShellOutput(installOffline) 87 | fmt.Println(str) 88 | return nil 89 | } 90 | 91 | //InstallOnline is 92 | func (e *Kubecore) InstallOnline() error { 93 | url := define.DownloadURL 94 | sh := pkg.RenderToStr(t, installOnlineWgetShTmpl, url) 95 | str := ApplyShellOutput(sh) 96 | fmt.Println(str) 97 | return nil 98 | } 99 | 100 | //Save is save bin files to bin dir, and save kubernetes core images 101 | func (e *Kubecore) Save() error { 102 | str := ApplyShellOutput(sh) 103 | fmt.Println(str) 104 | return nil 105 | } 106 | -------------------------------------------------------------------------------- /pkg/monitor/manifast.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fanux/kubeinit/0263b0b097a21a3b05a902dd3a2c5556e8ab0e8b/pkg/monitor/manifast.go -------------------------------------------------------------------------------- /pkg/monitor/run.go: -------------------------------------------------------------------------------- 1 | package monitor 2 | 3 | //Monitor is 4 | type Monitor struct{} 5 | 6 | //Info is 7 | func (e *Monitor) Info() (string, string) { 8 | return "monitor", nil 9 | } 10 | 11 | //Gen is 12 | func (e *Monitor) Gen() error { 13 | return nil 14 | } 15 | 16 | //Run is 17 | func (e *Monitor) Run() error { 18 | return nil 19 | } 20 | 21 | //Clean is 22 | func (e *Monitor) Clean() error { 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /pkg/net/manifast.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fanux/kubeinit/0263b0b097a21a3b05a902dd3a2c5556e8ab0e8b/pkg/net/manifast.go -------------------------------------------------------------------------------- /pkg/net/run.go: -------------------------------------------------------------------------------- 1 | package net 2 | 3 | //Net is 4 | type Net struct { 5 | } 6 | 7 | //Info is 8 | func (e *Net) Info() (string, string) { 9 | return "net", nil 10 | } 11 | 12 | //Gen is 13 | func (e *Net) Gen() error { 14 | return nil 15 | } 16 | 17 | //Run is 18 | func (e *Net) Run() error { 19 | return nil 20 | } 21 | 22 | //Clean is 23 | func (e *Net) Clean() error { 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /pkg/utils.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "html/template" 7 | "io/ioutil" 8 | "os" 9 | "os/exec" 10 | ) 11 | 12 | //RenderToStr is 13 | func RenderToStr(t *template.Template, tp string, args interface{}) string { 14 | template.Must(t.Parse(tp)) 15 | 16 | var buf []byte 17 | buffer := bytes.NewBuffer(buf) 18 | 19 | err = t.Execute(buffer, args) 20 | if err != nil { 21 | fmt.Println("exec template file error: %s", err) 22 | } 23 | str := buffer.String() 24 | return str 25 | } 26 | 27 | //Render is 28 | func Render(t *template.Template, tp string, args interface{}, outFile string) { 29 | template.Must(t.Parse(tp)) 30 | 31 | file, err := os.Create(outFile) 32 | defer file.Close() 33 | if err != nil { 34 | fmt.Println("create out file error: %s", err) 35 | return 36 | } 37 | 38 | err = t.Execute(file, args) 39 | if err != nil { 40 | fmt.Println("exec template file error: %s", err) 41 | } 42 | } 43 | 44 | //WriteFile is 45 | func WriteFile(fileName string, content string) { 46 | b := []byte(content) 47 | err := ioutil.WriteFile(fileName, b, 0644) 48 | if err != nil { 49 | fmt.Println("write file error", err) 50 | } 51 | } 52 | 53 | //ApplyShell is 54 | func ApplyShell(sh string) { 55 | fmt.Println("+ ", sh) 56 | cmd := exec.Command("bash", "-c", sh) 57 | cmd.Stdout = os.Stdout 58 | cmd.Stderr = os.Stderr 59 | cmd.Run() 60 | } 61 | 62 | //ApplyShellOutput is 63 | func ApplyShellOutput(sh string) string { 64 | fmt.Println("+ ", sh) 65 | s, err := exec.Command("bash", "-c", sh).Output() 66 | if err != nil { 67 | fmt.Println("exec shell failed: ", sh) 68 | return "" 69 | } 70 | return string(s) 71 | } 72 | -------------------------------------------------------------------------------- /save.sh: -------------------------------------------------------------------------------- 1 | # install docker 2 | yum install -y docker 3 | systemctl enable docker 4 | systemctl start docker 5 | 6 | # install kubeadm 7 | cat < /etc/yum.repos.d/kubernetes.repo 8 | [kubernetes] 9 | name=Kubernetes 10 | baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 11 | enabled=1 12 | gpgcheck=1 13 | repo_gpgcheck=1 14 | gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg 15 | EOF 16 | setenforce 0 17 | yum install -y kubelet kubeadm kubectl 18 | systemctl enable kubelet && systemctl start kubelet 19 | 20 | # disable selinux 21 | setenforce 0 22 | 23 | # iptable set 24 | cat < /etc/sysctl.d/k8s.conf 25 | net.bridge.bridge-nf-call-ip6tables = 1 26 | net.bridge.bridge-nf-call-iptables = 1 27 | EOF 28 | sysctl --system 29 | 30 | # gen config files 31 | TODO 32 | 33 | # init 34 | kubeadm init --config out/kubeadm.yaml 35 | mkdir -p $HOME/.kube 36 | cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 37 | 38 | # install calico 39 | wget https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml 40 | rm out/calico.yaml 41 | mv calico.yaml out 42 | kubectl apply -f out/calico.yaml 43 | 44 | # taint master 45 | kubectl taint nodes --all node-role.kubernetes.io/master- 46 | 47 | # install heapster 48 | git clone https://github.com/kubernetes/heapster 49 | mv deploy out/ 50 | rm -rf heapster 51 | kubectl create -f out/deploy/kube-config/influxdb/ 52 | kubectl create -f out/deploy/kube-config/rbac/heapster-rbac.yaml 53 | 54 | # install dashboard 55 | wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.1/src/deploy/recommended/kubernetes-dashboard.yaml 56 | rm out/kubernetes-dashboard.yaml 57 | mv kubernetes-dashboard.yaml out 58 | kubectl apply -f out/kubernetes-dashboard.yaml 59 | -------------------------------------------------------------------------------- /temp.sh: -------------------------------------------------------------------------------- 1 | ./kubeinit gen --master 172.21.161.28 --master 172.21.161.29 --master 172.21.161.30 \ 2 | --etcd 172.21.161.28 --etcd 172.21.161.29 --etcd 172.21.161.30 \ 3 | --version v1.9.2 \ 4 | --loadbalance 172.21.161.28 5 | -------------------------------------------------------------------------------- /test-alicloud.sh: -------------------------------------------------------------------------------- 1 | ./kubeinit gen --master 172.16.22.156 --master 172.16.22.155 --master 172.16.22.157 \ 2 | --etcd 172.16.22.155 --etcd 172.16.22.156 --etcd 172.16.22.157 \ 3 | --node 172.16.22.153 --node 172.16.22.154 \ 4 | --version v1.8.5 \ 5 | --loadbalance 172.16.22.155 6 | 7 | ./kubeinit apply -bie --passwd Fanux#123 8 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | ./kubeinit gen --master 192.168.11.16 --master 192.168.111.44 --master 192.168.111.50 \ 2 | --etcd 192.168.11.16 --etcd 192.168.111.44 --etcd 192.168.111.50 --etcd-image gcr.io/google_containers/etcd-amd64:3.1.11\ 3 | --version v1.9.2 \ 4 | --loadbalance 10.1.245.93 5 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - tip 6 | install: 7 | - go install ./... 8 | - go get github.com/BurntSushi/toml-test 9 | script: 10 | - export PATH="$PATH:$HOME/gopath/bin" 11 | - make test 12 | 13 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/.gitignore: -------------------------------------------------------------------------------- 1 | # Setup a Global .gitignore for OS and editor generated files: 2 | # https://help.github.com/articles/ignoring-files 3 | # git config --global core.excludesfile ~/.gitignore_global 4 | 5 | .vagrant 6 | *.sublime-project 7 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | 4 | go: 5 | - 1.5.4 6 | - 1.6.1 7 | - tip 8 | 9 | matrix: 10 | allow_failures: 11 | - go: tip 12 | 13 | before_script: 14 | - go get -u github.com/golang/lint/golint 15 | 16 | script: 17 | - go test -v --race ./... 18 | 19 | after_script: 20 | - test -z "$(gofmt -s -l -w . | tee /dev/stderr)" 21 | - test -z "$(golint ./... | tee /dev/stderr)" 22 | - go vet ./... 23 | 24 | os: 25 | - linux 26 | - osx 27 | 28 | notifications: 29 | email: false 30 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file as 2 | # Name or Organization 3 | # The email address is not required for organizations. 4 | 5 | # You can update this list using the following command: 6 | # 7 | # $ git shortlog -se | awk '{print $2 " " $3 " " $4}' 8 | 9 | # Please keep the list sorted. 10 | 11 | Adrien Bustany 12 | Amit Krishnan 13 | Bjørn Erik Pedersen 14 | Caleb Spare 15 | Case Nelson 16 | Chris Howey 17 | Christoffer Buchholz 18 | Daniel Wagner-Hall 19 | Dave Cheney 20 | Evan Phoenix 21 | Francisco Souza 22 | Hari haran 23 | John C Barstow 24 | Kelvin Fo 25 | Ken-ichirou MATSUZAWA 26 | Matt Layher 27 | Nathan Youngman 28 | Paul Hammond 29 | Pawel Knap 30 | Pieter Droogendijk 31 | Pursuit92 32 | Riku Voipio 33 | Rob Figueiredo 34 | Soge Zhang 35 | Tiffany Jernigan 36 | Tilak Sharma 37 | Travis Cline 38 | Tudor Golubenco 39 | Yukang 40 | bronze1man 41 | debrando 42 | henrikedwards 43 | 铁哥 44 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | Copyright (c) 2012 fsnotify Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/README.md: -------------------------------------------------------------------------------- 1 | # File system notifications for Go 2 | 3 | [![GoDoc](https://godoc.org/github.com/fsnotify/fsnotify?status.svg)](https://godoc.org/github.com/fsnotify/fsnotify) [![Go Report Card](https://goreportcard.com/badge/github.com/fsnotify/fsnotify)](https://goreportcard.com/report/github.com/fsnotify/fsnotify) [![Coverage](http://gocover.io/_badge/github.com/fsnotify/fsnotify)](http://gocover.io/github.com/fsnotify/fsnotify) 4 | 5 | fsnotify utilizes [golang.org/x/sys](https://godoc.org/golang.org/x/sys) rather than `syscall` from the standard library. Ensure you have the latest version installed by running: 6 | 7 | ```console 8 | go get -u golang.org/x/sys/... 9 | ``` 10 | 11 | Cross platform: Windows, Linux, BSD and OS X. 12 | 13 | |Adapter |OS |Status | 14 | |----------|----------|----------| 15 | |inotify |Linux 2.6.27 or later, Android\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)| 16 | |kqueue |BSD, OS X, iOS\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)| 17 | |ReadDirectoryChangesW|Windows|Supported [![Build status](https://ci.appveyor.com/api/projects/status/ivwjubaih4r0udeh/branch/master?svg=true)](https://ci.appveyor.com/project/NathanYoungman/fsnotify/branch/master)| 18 | |FSEvents |OS X |[Planned](https://github.com/fsnotify/fsnotify/issues/11)| 19 | |FEN |Solaris 11 |[In Progress](https://github.com/fsnotify/fsnotify/issues/12)| 20 | |fanotify |Linux 2.6.37+ | | 21 | |USN Journals |Windows |[Maybe](https://github.com/fsnotify/fsnotify/issues/53)| 22 | |Polling |*All* |[Maybe](https://github.com/fsnotify/fsnotify/issues/9)| 23 | 24 | \* Android and iOS are untested. 25 | 26 | Please see [the documentation](https://godoc.org/github.com/fsnotify/fsnotify) for usage. Consult the [Wiki](https://github.com/fsnotify/fsnotify/wiki) for the FAQ and further information. 27 | 28 | ## API stability 29 | 30 | fsnotify is a fork of [howeyc/fsnotify](https://godoc.org/github.com/howeyc/fsnotify) with a new API as of v1.0. The API is based on [this design document](http://goo.gl/MrYxyA). 31 | 32 | All [releases](https://github.com/fsnotify/fsnotify/releases) are tagged based on [Semantic Versioning](http://semver.org/). Further API changes are [planned](https://github.com/fsnotify/fsnotify/milestones), and will be tagged with a new major revision number. 33 | 34 | Go 1.6 supports dependencies located in the `vendor/` folder. Unless you are creating a library, it is recommended that you copy fsnotify into `vendor/github.com/fsnotify/fsnotify` within your project, and likewise for `golang.org/x/sys`. 35 | 36 | ## Contributing 37 | 38 | Please refer to [CONTRIBUTING][] before opening an issue or pull request. 39 | 40 | ## Example 41 | 42 | See [example_test.go](https://github.com/fsnotify/fsnotify/blob/master/example_test.go). 43 | 44 | [contributing]: https://github.com/fsnotify/fsnotify/blob/master/CONTRIBUTING.md 45 | 46 | ## Related Projects 47 | 48 | * [notify](https://github.com/rjeczalik/notify) 49 | * [fsevents](https://github.com/fsnotify/fsevents) 50 | 51 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/fen.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 solaris 6 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | ) 12 | 13 | // Watcher watches a set of files, delivering events to a channel. 14 | type Watcher struct { 15 | Events chan Event 16 | Errors chan error 17 | } 18 | 19 | // NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. 20 | func NewWatcher() (*Watcher, error) { 21 | return nil, errors.New("FEN based watcher not yet supported for fsnotify\n") 22 | } 23 | 24 | // Close removes all watches and closes the events channel. 25 | func (w *Watcher) Close() error { 26 | return nil 27 | } 28 | 29 | // Add starts watching the named file or directory (non-recursively). 30 | func (w *Watcher) Add(name string) error { 31 | return nil 32 | } 33 | 34 | // Remove stops watching the the named file or directory (non-recursively). 35 | func (w *Watcher) Remove(name string) error { 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/fsnotify.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 !plan9 6 | 7 | // Package fsnotify provides a platform-independent interface for file system notifications. 8 | package fsnotify 9 | 10 | import ( 11 | "bytes" 12 | "fmt" 13 | ) 14 | 15 | // Event represents a single file system notification. 16 | type Event struct { 17 | Name string // Relative path to the file or directory. 18 | Op Op // File operation that triggered the event. 19 | } 20 | 21 | // Op describes a set of file operations. 22 | type Op uint32 23 | 24 | // These are the generalized file operations that can trigger a notification. 25 | const ( 26 | Create Op = 1 << iota 27 | Write 28 | Remove 29 | Rename 30 | Chmod 31 | ) 32 | 33 | // String returns a string representation of the event in the form 34 | // "file: REMOVE|WRITE|..." 35 | func (e Event) String() string { 36 | // Use a buffer for efficient string concatenation 37 | var buffer bytes.Buffer 38 | 39 | if e.Op&Create == Create { 40 | buffer.WriteString("|CREATE") 41 | } 42 | if e.Op&Remove == Remove { 43 | buffer.WriteString("|REMOVE") 44 | } 45 | if e.Op&Write == Write { 46 | buffer.WriteString("|WRITE") 47 | } 48 | if e.Op&Rename == Rename { 49 | buffer.WriteString("|RENAME") 50 | } 51 | if e.Op&Chmod == Chmod { 52 | buffer.WriteString("|CHMOD") 53 | } 54 | 55 | // If buffer remains empty, return no event names 56 | if buffer.Len() == 0 { 57 | return fmt.Sprintf("%q: ", e.Name) 58 | } 59 | 60 | // Return a list of event names, with leading pipe character stripped 61 | return fmt.Sprintf("%q: %s", e.Name, buffer.String()[1:]) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd openbsd netbsd dragonfly 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const openMode = unix.O_NONBLOCK | unix.O_RDONLY 12 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | // note: this constant is not defined on BSD 12 | const openMode = unix.O_EVTONLY 13 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/.gitignore: -------------------------------------------------------------------------------- 1 | y.output 2 | 3 | # ignore intellij files 4 | .idea 5 | *.iml 6 | *.ipr 7 | *.iws 8 | 9 | *.test 10 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 1.5 4 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/Makefile: -------------------------------------------------------------------------------- 1 | TEST?=./... 2 | 3 | default: test 4 | 5 | fmt: generate 6 | go fmt ./... 7 | 8 | test: generate 9 | go test $(TEST) $(TESTARGS) 10 | 11 | generate: 12 | go generate ./... 13 | 14 | updatedeps: 15 | go get -u golang.org/x/tools/cmd/stringer 16 | 17 | .PHONY: default generate test updatedeps 18 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "build-{branch}-{build}" 2 | image: Visual Studio 2015 3 | clone_folder: c:\gopath\src\github.com\hashicorp\hcl 4 | environment: 5 | GOPATH: c:\gopath 6 | init: 7 | - git config --global core.autocrlf true 8 | install: 9 | - cmd: >- 10 | echo %Path% 11 | 12 | go version 13 | 14 | go env 15 | build_script: 16 | - cmd: go test -v ./... 17 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl.go: -------------------------------------------------------------------------------- 1 | // Package hcl decodes HCL into usable Go structures. 2 | // 3 | // hcl input can come in either pure HCL format or JSON format. 4 | // It can be parsed into an AST, and then decoded into a structure, 5 | // or it can be decoded directly from a string into a structure. 6 | // 7 | // If you choose to parse HCL into a raw AST, the benefit is that you 8 | // can write custom visitor implementations to implement custom 9 | // semantic checks. By default, HCL does not perform any semantic 10 | // checks. 11 | package hcl 12 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/ast/walk.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import "fmt" 4 | 5 | // WalkFunc describes a function to be called for each node during a Walk. The 6 | // returned node can be used to rewrite the AST. Walking stops the returned 7 | // bool is false. 8 | type WalkFunc func(Node) (Node, bool) 9 | 10 | // Walk traverses an AST in depth-first order: It starts by calling fn(node); 11 | // node must not be nil. If fn returns true, Walk invokes fn recursively for 12 | // each of the non-nil children of node, followed by a call of fn(nil). The 13 | // returned node of fn can be used to rewrite the passed node to fn. 14 | func Walk(node Node, fn WalkFunc) Node { 15 | rewritten, ok := fn(node) 16 | if !ok { 17 | return rewritten 18 | } 19 | 20 | switch n := node.(type) { 21 | case *File: 22 | n.Node = Walk(n.Node, fn) 23 | case *ObjectList: 24 | for i, item := range n.Items { 25 | n.Items[i] = Walk(item, fn).(*ObjectItem) 26 | } 27 | case *ObjectKey: 28 | // nothing to do 29 | case *ObjectItem: 30 | for i, k := range n.Keys { 31 | n.Keys[i] = Walk(k, fn).(*ObjectKey) 32 | } 33 | 34 | if n.Val != nil { 35 | n.Val = Walk(n.Val, fn) 36 | } 37 | case *LiteralType: 38 | // nothing to do 39 | case *ListType: 40 | for i, l := range n.List { 41 | n.List[i] = Walk(l, fn) 42 | } 43 | case *ObjectType: 44 | n.List = Walk(n.List, fn).(*ObjectList) 45 | default: 46 | // should we panic here? 47 | fmt.Printf("unknown type: %T\n", n) 48 | } 49 | 50 | fn(nil) 51 | return rewritten 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/parser/error.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/hashicorp/hcl/hcl/token" 7 | ) 8 | 9 | // PosError is a parse error that contains a position. 10 | type PosError struct { 11 | Pos token.Pos 12 | Err error 13 | } 14 | 15 | func (e *PosError) Error() string { 16 | return fmt.Sprintf("At %s: %s", e.Pos, e.Err) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/token/position.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import "fmt" 4 | 5 | // Pos describes an arbitrary source position 6 | // including the file, line, and column location. 7 | // A Position is valid if the line number is > 0. 8 | type Pos struct { 9 | Filename string // filename, if any 10 | Offset int // offset, starting at 0 11 | Line int // line number, starting at 1 12 | Column int // column number, starting at 1 (character count) 13 | } 14 | 15 | // IsValid returns true if the position is valid. 16 | func (p *Pos) IsValid() bool { return p.Line > 0 } 17 | 18 | // String returns a string in one of several forms: 19 | // 20 | // file:line:column valid position with file name 21 | // line:column valid position without file name 22 | // file invalid position with file name 23 | // - invalid position without file name 24 | func (p Pos) String() string { 25 | s := p.Filename 26 | if p.IsValid() { 27 | if s != "" { 28 | s += ":" 29 | } 30 | s += fmt.Sprintf("%d:%d", p.Line, p.Column) 31 | } 32 | if s == "" { 33 | s = "-" 34 | } 35 | return s 36 | } 37 | 38 | // Before reports whether the position p is before u. 39 | func (p Pos) Before(u Pos) bool { 40 | return u.Offset > p.Offset || u.Line > p.Line 41 | } 42 | 43 | // After reports whether the position p is after u. 44 | func (p Pos) After(u Pos) bool { 45 | return u.Offset < p.Offset || u.Line < p.Line 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/json/token/position.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import "fmt" 4 | 5 | // Pos describes an arbitrary source position 6 | // including the file, line, and column location. 7 | // A Position is valid if the line number is > 0. 8 | type Pos struct { 9 | Filename string // filename, if any 10 | Offset int // offset, starting at 0 11 | Line int // line number, starting at 1 12 | Column int // column number, starting at 1 (character count) 13 | } 14 | 15 | // IsValid returns true if the position is valid. 16 | func (p *Pos) IsValid() bool { return p.Line > 0 } 17 | 18 | // String returns a string in one of several forms: 19 | // 20 | // file:line:column valid position with file name 21 | // line:column valid position without file name 22 | // file invalid position with file name 23 | // - invalid position without file name 24 | func (p Pos) String() string { 25 | s := p.Filename 26 | if p.IsValid() { 27 | if s != "" { 28 | s += ":" 29 | } 30 | s += fmt.Sprintf("%d:%d", p.Line, p.Column) 31 | } 32 | if s == "" { 33 | s = "-" 34 | } 35 | return s 36 | } 37 | 38 | // Before reports whether the position p is before u. 39 | func (p Pos) Before(u Pos) bool { 40 | return u.Offset > p.Offset || u.Line > p.Line 41 | } 42 | 43 | // After reports whether the position p is after u. 44 | func (p Pos) After(u Pos) bool { 45 | return u.Offset < p.Offset || u.Line < p.Line 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/lex.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "unicode" 5 | "unicode/utf8" 6 | ) 7 | 8 | type lexModeValue byte 9 | 10 | const ( 11 | lexModeUnknown lexModeValue = iota 12 | lexModeHcl 13 | lexModeJson 14 | ) 15 | 16 | // lexMode returns whether we're going to be parsing in JSON 17 | // mode or HCL mode. 18 | func lexMode(v []byte) lexModeValue { 19 | var ( 20 | r rune 21 | w int 22 | offset int 23 | ) 24 | 25 | for { 26 | r, w = utf8.DecodeRune(v[offset:]) 27 | offset += w 28 | if unicode.IsSpace(r) { 29 | continue 30 | } 31 | if r == '{' { 32 | return lexModeJson 33 | } 34 | break 35 | } 36 | 37 | return lexModeHcl 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/parse.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/hashicorp/hcl/hcl/ast" 7 | hclParser "github.com/hashicorp/hcl/hcl/parser" 8 | jsonParser "github.com/hashicorp/hcl/json/parser" 9 | ) 10 | 11 | // ParseBytes accepts as input byte slice and returns ast tree. 12 | // 13 | // Input can be either JSON or HCL 14 | func ParseBytes(in []byte) (*ast.File, error) { 15 | return parse(in) 16 | } 17 | 18 | // ParseString accepts input as a string and returns ast tree. 19 | func ParseString(input string) (*ast.File, error) { 20 | return parse([]byte(input)) 21 | } 22 | 23 | func parse(in []byte) (*ast.File, error) { 24 | switch lexMode(in) { 25 | case lexModeHcl: 26 | return hclParser.Parse(in) 27 | case lexModeJson: 28 | return jsonParser.Parse(in) 29 | } 30 | 31 | return nil, fmt.Errorf("unknown config format") 32 | } 33 | 34 | // Parse parses the given input and returns the root object. 35 | // 36 | // The input format can be either HCL or JSON. 37 | func Parse(input string) (*ast.File, error) { 38 | return parse([]byte(input)) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/README.md: -------------------------------------------------------------------------------- 1 | # mousetrap 2 | 3 | mousetrap is a tiny library that answers a single question. 4 | 5 | On a Windows machine, was the process invoked by someone double clicking on 6 | the executable file while browsing in explorer? 7 | 8 | ### Motivation 9 | 10 | Windows developers unfamiliar with command line tools will often "double-click" 11 | the executable for a tool. Because most CLI tools print the help and then exit 12 | when invoked without arguments, this is often very frustrating for those users. 13 | 14 | mousetrap provides a way to detect these invocations so that you can provide 15 | more helpful behavior and instructions on how to run the CLI tool. To see what 16 | this looks like, both from an organizational and a technical perspective, see 17 | https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ 18 | 19 | ### The interface 20 | 21 | The library exposes a single interface: 22 | 23 | func StartedByExplorer() (bool) 24 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package mousetrap 4 | 5 | // StartedByExplorer returns true if the program was invoked by the user 6 | // double-clicking on the executable from explorer.exe 7 | // 8 | // It is conservative and returns false if any of the internal calls fail. 9 | // It does not guarantee that the program was run from a terminal. It only can tell you 10 | // whether it was launched from explorer.exe 11 | // 12 | // On non-Windows platforms, it always returns false. 13 | func StartedByExplorer() bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | // defined by the Win32 API 15 | th32cs_snapprocess uintptr = 0x2 16 | ) 17 | 18 | var ( 19 | kernel = syscall.MustLoadDLL("kernel32.dll") 20 | CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot") 21 | Process32First = kernel.MustFindProc("Process32FirstW") 22 | Process32Next = kernel.MustFindProc("Process32NextW") 23 | ) 24 | 25 | // ProcessEntry32 structure defined by the Win32 API 26 | type processEntry32 struct { 27 | dwSize uint32 28 | cntUsage uint32 29 | th32ProcessID uint32 30 | th32DefaultHeapID int 31 | th32ModuleID uint32 32 | cntThreads uint32 33 | th32ParentProcessID uint32 34 | pcPriClassBase int32 35 | dwFlags uint32 36 | szExeFile [syscall.MAX_PATH]uint16 37 | } 38 | 39 | func getProcessEntry(pid int) (pe *processEntry32, err error) { 40 | snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0)) 41 | if snapshot == uintptr(syscall.InvalidHandle) { 42 | err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1) 43 | return 44 | } 45 | defer syscall.CloseHandle(syscall.Handle(snapshot)) 46 | 47 | var processEntry processEntry32 48 | processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) 49 | ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 50 | if ok == 0 { 51 | err = fmt.Errorf("Process32First: %v", e1) 52 | return 53 | } 54 | 55 | for { 56 | if processEntry.th32ProcessID == uint32(pid) { 57 | pe = &processEntry 58 | return 59 | } 60 | 61 | ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 62 | if ok == 0 { 63 | err = fmt.Errorf("Process32Next: %v", e1) 64 | return 65 | } 66 | } 67 | } 68 | 69 | func getppid() (pid int, err error) { 70 | pe, err := getProcessEntry(os.Getpid()) 71 | if err != nil { 72 | return 73 | } 74 | 75 | pid = int(pe.th32ParentProcessID) 76 | return 77 | } 78 | 79 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 80 | // on the executable from explorer.exe 81 | // 82 | // It is conservative and returns false if any of the internal calls fail. 83 | // It does not guarantee that the program was run from a terminal. It only can tell you 84 | // whether it was launched from explorer.exe 85 | func StartedByExplorer() bool { 86 | ppid, err := getppid() 87 | if err != nil { 88 | return false 89 | } 90 | 91 | pe, err := getProcessEntry(ppid) 92 | if err != nil { 93 | return false 94 | } 95 | 96 | name := syscall.UTF16ToString(pe.szExeFile[:]) 97 | return name == "explorer.exe" 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "os" 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { 13 | snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer syscall.CloseHandle(snapshot) 18 | var procEntry syscall.ProcessEntry32 19 | procEntry.Size = uint32(unsafe.Sizeof(procEntry)) 20 | if err = syscall.Process32First(snapshot, &procEntry); err != nil { 21 | return nil, err 22 | } 23 | for { 24 | if procEntry.ProcessID == uint32(pid) { 25 | return &procEntry, nil 26 | } 27 | err = syscall.Process32Next(snapshot, &procEntry) 28 | if err != nil { 29 | return nil, err 30 | } 31 | } 32 | } 33 | 34 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 35 | // on the executable from explorer.exe 36 | // 37 | // It is conservative and returns false if any of the internal calls fail. 38 | // It does not guarantee that the program was run from a terminal. It only can tell you 39 | // whether it was launched from explorer.exe 40 | func StartedByExplorer() bool { 41 | pe, err := getProcessEntry(os.Getppid()) 42 | if err != nil { 43 | return false 44 | } 45 | return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/.gitignore: -------------------------------------------------------------------------------- 1 | *.sublime-project 2 | *.sublime-workspace 3 | *.un~ 4 | *.swp 5 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.4.3 4 | - 1.5.3 5 | - 1.6 6 | - tip 7 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/LICENSE: -------------------------------------------------------------------------------- 1 | goproperties - properties file decoder for Go 2 | 3 | Copyright (c) 2013-2014 - Frank Schroeder 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/README.md: -------------------------------------------------------------------------------- 1 | Overview [![Build Status](https://travis-ci.org/magiconair/properties.svg?branch=master)](https://travis-ci.org/magiconair/properties) 2 | ======== 3 | 4 | #### Current version: 1.7.0 5 | 6 | properties is a Go library for reading and writing properties files. 7 | 8 | It supports reading from multiple files or URLs and Spring style recursive 9 | property expansion of expressions like `${key}` to their corresponding value. 10 | Value expressions can refer to other keys like in `${key}` or to environment 11 | variables like in `${USER}`. Filenames can also contain environment variables 12 | like in `/home/${USER}/myapp.properties`. 13 | 14 | Properties can be decoded into structs, maps, arrays and values through 15 | struct tags. 16 | 17 | Comments and the order of keys are preserved. Comments can be modified 18 | and can be written to the output. 19 | 20 | The properties library supports both ISO-8859-1 and UTF-8 encoded data. 21 | 22 | Starting from version 1.3.0 the behavior of the MustXXX() functions is 23 | configurable by providing a custom `ErrorHandler` function. The default has 24 | changed from `panic` to `log.Fatal` but this is configurable and custom 25 | error handling functions can be provided. See the package documentation for 26 | details. 27 | 28 | Getting Started 29 | --------------- 30 | 31 | ```go 32 | import ( 33 | "flag" 34 | "github.com/magiconair/properties" 35 | ) 36 | 37 | func main() { 38 | p := properties.MustLoadFile("${HOME}/config.properties", properties.UTF8) 39 | 40 | // via getters 41 | host := p.MustGetString("host") 42 | port := p.GetInt("port", 8080) 43 | 44 | // or via decode 45 | type Config struct { 46 | Host string `properties:"host"` 47 | Port int `properties:"port,default=9000"` 48 | Accept []string `properties:"accept,default=image/png;image;gif"` 49 | Timeout time.Duration `properties:"timeout,default=5s"` 50 | } 51 | var cfg Config 52 | if err := p.Decode(&cfg); err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // or via flags 57 | p.MustFlag(flag.CommandLine) 58 | 59 | // or via url 60 | p = properties.MustLoadURL("http://host/path") 61 | } 62 | 63 | ``` 64 | 65 | Read the full documentation on [GoDoc](https://godoc.org/github.com/magiconair/properties) [![GoDoc](https://godoc.org/github.com/magiconair/properties?status.png)](https://godoc.org/github.com/magiconair/properties) 66 | 67 | Installation and Upgrade 68 | ------------------------ 69 | 70 | ``` 71 | $ go get -u github.com/magiconair/properties 72 | ``` 73 | 74 | License 75 | ------- 76 | 77 | 2 clause BSD license. See [LICENSE](https://github.com/magiconair/properties/blob/master/LICENSE) file for details. 78 | 79 | ToDo 80 | ---- 81 | * Dump contents with passwords and secrets obscured 82 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/integrate.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Frank Schroeder. 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 properties 6 | 7 | import "flag" 8 | 9 | // MustFlag sets flags that are skipped by dst.Parse when p contains 10 | // the respective key for flag.Flag.Name. 11 | // 12 | // It's use is recommended with command line arguments as in: 13 | // flag.Parse() 14 | // p.MustFlag(flag.CommandLine) 15 | func (p *Properties) MustFlag(dst *flag.FlagSet) { 16 | m := make(map[string]*flag.Flag) 17 | dst.VisitAll(func(f *flag.Flag) { 18 | m[f.Name] = f 19 | }) 20 | dst.Visit(func(f *flag.Flag) { 21 | delete(m, f.Name) // overridden 22 | }) 23 | 24 | for name, f := range m { 25 | v, ok := p.Get(name) 26 | if !ok { 27 | continue 28 | } 29 | 30 | if err := f.Value.Set(v); err != nil { 31 | ErrorHandler(err) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/parser.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Frank Schroeder. 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 properties 6 | 7 | import ( 8 | "fmt" 9 | "runtime" 10 | ) 11 | 12 | type parser struct { 13 | lex *lexer 14 | } 15 | 16 | func parse(input string) (properties *Properties, err error) { 17 | p := &parser{lex: lex(input)} 18 | defer p.recover(&err) 19 | 20 | properties = NewProperties() 21 | key := "" 22 | comments := []string{} 23 | 24 | for { 25 | token := p.expectOneOf(itemComment, itemKey, itemEOF) 26 | switch token.typ { 27 | case itemEOF: 28 | goto done 29 | case itemComment: 30 | comments = append(comments, token.val) 31 | continue 32 | case itemKey: 33 | key = token.val 34 | if _, ok := properties.m[key]; !ok { 35 | properties.k = append(properties.k, key) 36 | } 37 | } 38 | 39 | token = p.expectOneOf(itemValue, itemEOF) 40 | if len(comments) > 0 { 41 | properties.c[key] = comments 42 | comments = []string{} 43 | } 44 | switch token.typ { 45 | case itemEOF: 46 | properties.m[key] = "" 47 | goto done 48 | case itemValue: 49 | properties.m[key] = token.val 50 | } 51 | } 52 | 53 | done: 54 | return properties, nil 55 | } 56 | 57 | func (p *parser) errorf(format string, args ...interface{}) { 58 | format = fmt.Sprintf("properties: Line %d: %s", p.lex.lineNumber(), format) 59 | panic(fmt.Errorf(format, args...)) 60 | } 61 | 62 | func (p *parser) expect(expected itemType) (token item) { 63 | token = p.lex.nextItem() 64 | if token.typ != expected { 65 | p.unexpected(token) 66 | } 67 | return token 68 | } 69 | 70 | func (p *parser) expectOneOf(expected ...itemType) (token item) { 71 | token = p.lex.nextItem() 72 | for _, v := range expected { 73 | if token.typ == v { 74 | return token 75 | } 76 | } 77 | p.unexpected(token) 78 | panic("unexpected token") 79 | } 80 | 81 | func (p *parser) unexpected(token item) { 82 | p.errorf(token.String()) 83 | } 84 | 85 | // recover is the handler that turns panics into returns from the top level of Parse. 86 | func (p *parser) recover(errp *error) { 87 | e := recover() 88 | if e != nil { 89 | if _, ok := e.(runtime.Error); ok { 90 | panic(e) 91 | } 92 | *errp = e.(error) 93 | } 94 | return 95 | } 96 | -------------------------------------------------------------------------------- /vendor/github.com/magiconair/properties/rangecheck.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Frank Schroeder. 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 properties 6 | 7 | import ( 8 | "fmt" 9 | "math" 10 | ) 11 | 12 | // make this a var to overwrite it in a test 13 | var is32Bit = ^uint(0) == math.MaxUint32 14 | 15 | // intRangeCheck checks if the value fits into the int type and 16 | // panics if it does not. 17 | func intRangeCheck(key string, v int64) int { 18 | if is32Bit && (v < math.MinInt32 || v > math.MaxInt32) { 19 | panic(fmt.Sprintf("Value %d for key %s out of range", v, key)) 20 | } 21 | return int(v) 22 | } 23 | 24 | // uintRangeCheck checks if the value fits into the uint type and 25 | // panics if it does not. 26 | func uintRangeCheck(key string, v uint64) uint { 27 | if is32Bit && v > math.MaxUint32 { 28 | panic(fmt.Sprintf("Value %d for key %s out of range", v, key)) 29 | } 30 | return uint(v) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Mitchell Hashimoto 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 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/README.md: -------------------------------------------------------------------------------- 1 | # mapstructure 2 | 3 | mapstructure is a Go library for decoding generic map values to structures 4 | and vice versa, while providing helpful error handling. 5 | 6 | This library is most useful when decoding values from some data stream (JSON, 7 | Gob, etc.) where you don't _quite_ know the structure of the underlying data 8 | until you read a part of it. You can therefore read a `map[string]interface{}` 9 | and use this library to decode it into the proper underlying native Go 10 | structure. 11 | 12 | ## Installation 13 | 14 | Standard `go get`: 15 | 16 | ``` 17 | $ go get github.com/mitchellh/mapstructure 18 | ``` 19 | 20 | ## Usage & Example 21 | 22 | For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/mapstructure). 23 | 24 | The `Decode` function has examples associated with it there. 25 | 26 | ## But Why?! 27 | 28 | Go offers fantastic standard libraries for decoding formats such as JSON. 29 | The standard method is to have a struct pre-created, and populate that struct 30 | from the bytes of the encoded format. This is great, but the problem is if 31 | you have configuration or an encoding that changes slightly depending on 32 | specific fields. For example, consider this JSON: 33 | 34 | ```json 35 | { 36 | "type": "person", 37 | "name": "Mitchell" 38 | } 39 | ``` 40 | 41 | Perhaps we can't populate a specific structure without first reading 42 | the "type" field from the JSON. We could always do two passes over the 43 | decoding of the JSON (reading the "type" first, and the rest later). 44 | However, it is much simpler to just decode this into a `map[string]interface{}` 45 | structure, read the "type" key, then use something like this library 46 | to decode it into the proper structure. 47 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/decode_hooks.go: -------------------------------------------------------------------------------- 1 | package mapstructure 2 | 3 | import ( 4 | "reflect" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // ComposeDecodeHookFunc creates a single DecodeHookFunc that 10 | // automatically composes multiple DecodeHookFuncs. 11 | // 12 | // The composed funcs are called in order, with the result of the 13 | // previous transformation. 14 | func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { 15 | return func( 16 | f reflect.Kind, 17 | t reflect.Kind, 18 | data interface{}) (interface{}, error) { 19 | var err error 20 | for _, f1 := range fs { 21 | data, err = f1(f, t, data) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | // Modify the from kind to be correct with the new data 27 | f = getKind(reflect.ValueOf(data)) 28 | } 29 | 30 | return data, nil 31 | } 32 | } 33 | 34 | // StringToSliceHookFunc returns a DecodeHookFunc that converts 35 | // string to []string by splitting on the given sep. 36 | func StringToSliceHookFunc(sep string) DecodeHookFunc { 37 | return func( 38 | f reflect.Kind, 39 | t reflect.Kind, 40 | data interface{}) (interface{}, error) { 41 | if f != reflect.String || t != reflect.Slice { 42 | return data, nil 43 | } 44 | 45 | raw := data.(string) 46 | if raw == "" { 47 | return []string{}, nil 48 | } 49 | 50 | return strings.Split(raw, sep), nil 51 | } 52 | } 53 | 54 | func WeaklyTypedHook( 55 | f reflect.Kind, 56 | t reflect.Kind, 57 | data interface{}) (interface{}, error) { 58 | dataVal := reflect.ValueOf(data) 59 | switch t { 60 | case reflect.String: 61 | switch f { 62 | case reflect.Bool: 63 | if dataVal.Bool() { 64 | return "1", nil 65 | } else { 66 | return "0", nil 67 | } 68 | case reflect.Float32: 69 | return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil 70 | case reflect.Int: 71 | return strconv.FormatInt(dataVal.Int(), 10), nil 72 | case reflect.Slice: 73 | dataType := dataVal.Type() 74 | elemKind := dataType.Elem().Kind() 75 | if elemKind == reflect.Uint8 { 76 | return string(dataVal.Interface().([]uint8)), nil 77 | } 78 | case reflect.Uint: 79 | return strconv.FormatUint(dataVal.Uint(), 10), nil 80 | } 81 | } 82 | 83 | return data, nil 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/error.go: -------------------------------------------------------------------------------- 1 | package mapstructure 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Error implements the error interface and can represents multiple 9 | // errors that occur in the course of a single decode. 10 | type Error struct { 11 | Errors []string 12 | } 13 | 14 | func (e *Error) Error() string { 15 | points := make([]string, len(e.Errors)) 16 | for i, err := range e.Errors { 17 | points[i] = fmt.Sprintf("* %s", err) 18 | } 19 | 20 | return fmt.Sprintf( 21 | "%d error(s) decoding:\n\n%s", 22 | len(e.Errors), strings.Join(points, "\n")) 23 | } 24 | 25 | func appendErrors(errors []string, err error) []string { 26 | switch e := err.(type) { 27 | case *Error: 28 | return append(errors, e.Errors...) 29 | default: 30 | return append(errors, e.Error()) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cast/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cast/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Steve Francia 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. -------------------------------------------------------------------------------- /vendor/github.com/spf13/cast/README.md: -------------------------------------------------------------------------------- 1 | cast 2 | ==== 3 | 4 | Easy and safe casting from one type to another in Go 5 | 6 | Don’t Panic! ... Cast 7 | 8 | ## What is Cast? 9 | 10 | Cast is a library to convert between different go types in a consistent and easy way. 11 | 12 | Cast provides simple functions to easily convert a number to a string, an 13 | interface into a bool, etc. Cast does this intelligently when an obvious 14 | conversion is possible. It doesn’t make any attempts to guess what you meant, 15 | for example you can only convert a string to an int when it is a string 16 | representation of an int such as “8”. Cast was developed for use in 17 | [Hugo](http://hugo.spf13.com), a website engine which uses YAML, TOML or JSON 18 | for meta data. 19 | 20 | ## Why use Cast? 21 | 22 | When working with dynamic data in Go you often need to cast or convert the data 23 | from one type into another. Cast goes beyond just using type assertion (though 24 | it uses that when possible) to provide a very straightforward and convenient 25 | library. 26 | 27 | If you are working with interfaces to handle things like dynamic content 28 | you’ll need an easy way to convert an interface into a given type. This 29 | is the library for you. 30 | 31 | If you are taking in data from YAML, TOML or JSON or other formats which lack 32 | full types, then Cast is the library for you. 33 | 34 | ## Usage 35 | 36 | Cast provides a handful of To_____ methods. These methods will always return 37 | the desired type. **If input is provided that will not convert to that type, the 38 | 0 or nil value for that type will be returned**. 39 | 40 | Cast also provides identical methods To_____E. These return the same result as 41 | the To_____ methods, plus an additional error which tells you if it successfully 42 | converted. Using these methods you can tell the difference between when the 43 | input matched the zero value or when the conversion failed and the zero value 44 | was returned. 45 | 46 | The following examples are merely a sample of what is available. Please review 47 | the code for a complete set. 48 | 49 | ### Example ‘ToString’: 50 | 51 | cast.ToString("mayonegg") // "mayonegg" 52 | cast.ToString(8) // "8" 53 | cast.ToString(8.31) // "8.31" 54 | cast.ToString([]byte("one time")) // "one time" 55 | cast.ToString(nil) // "" 56 | 57 | var foo interface{} = "one more time" 58 | cast.ToString(foo) // "one more time" 59 | 60 | 61 | ### Example ‘ToInt’: 62 | 63 | cast.ToInt(8) // 8 64 | cast.ToInt(8.31) // 8 65 | cast.ToInt("8") // 8 66 | cast.ToInt(true) // 1 67 | cast.ToInt(false) // 0 68 | 69 | var eight interface{} = 8 70 | cast.ToInt(eight) // 8 71 | cast.ToInt(nil) // 0 72 | 73 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cast/cast.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2014 Steve Francia . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package cast 7 | 8 | import "time" 9 | 10 | func ToBool(i interface{}) bool { 11 | v, _ := ToBoolE(i) 12 | return v 13 | } 14 | 15 | func ToTime(i interface{}) time.Time { 16 | v, _ := ToTimeE(i) 17 | return v 18 | } 19 | 20 | func ToDuration(i interface{}) time.Duration { 21 | v, _ := ToDurationE(i) 22 | return v 23 | } 24 | 25 | func ToFloat64(i interface{}) float64 { 26 | v, _ := ToFloat64E(i) 27 | return v 28 | } 29 | 30 | func ToInt64(i interface{}) int64 { 31 | v, _ := ToInt64E(i) 32 | return v 33 | } 34 | 35 | func ToInt(i interface{}) int { 36 | v, _ := ToIntE(i) 37 | return v 38 | } 39 | 40 | func ToString(i interface{}) string { 41 | v, _ := ToStringE(i) 42 | return v 43 | } 44 | 45 | func ToStringMapString(i interface{}) map[string]string { 46 | v, _ := ToStringMapStringE(i) 47 | return v 48 | } 49 | 50 | func ToStringMapStringSlice(i interface{}) map[string][]string { 51 | v, _ := ToStringMapStringSliceE(i) 52 | return v 53 | } 54 | 55 | func ToStringMapBool(i interface{}) map[string]bool { 56 | v, _ := ToStringMapBoolE(i) 57 | return v 58 | } 59 | 60 | func ToStringMap(i interface{}) map[string]interface{} { 61 | v, _ := ToStringMapE(i) 62 | return v 63 | } 64 | 65 | func ToSlice(i interface{}) []interface{} { 66 | v, _ := ToSliceE(i) 67 | return v 68 | } 69 | 70 | func ToStringSlice(i interface{}) []string { 71 | v, _ := ToStringSliceE(i) 72 | return v 73 | } 74 | 75 | func ToIntSlice(i interface{}) []int { 76 | v, _ := ToIntSliceE(i) 77 | return v 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | cobra.test 25 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.mailmap: -------------------------------------------------------------------------------- 1 | Steve Francia 2 | Bjørn Erik Pedersen 3 | Fabiano Franz 4 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3.3 4 | - 1.4.2 5 | - 1.5.1 6 | - tip 7 | before_install: 8 | - mkdir -p bin 9 | - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck 10 | - chmod +x bin/shellcheck 11 | script: 12 | - PATH=$PATH:$PWD/bin go test -v ./... 13 | - go build 14 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package cobra 4 | 5 | var preExecHookFn func(*Command) 6 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package cobra 4 | 5 | import ( 6 | "os" 7 | "time" 8 | 9 | "github.com/inconshreveable/mousetrap" 10 | ) 11 | 12 | var preExecHookFn = preExecHook 13 | 14 | // enables an information splash screen on Windows if the CLI is started from explorer.exe. 15 | var MousetrapHelpText string = `This is a command line tool 16 | 17 | You need to open cmd.exe and run it from there. 18 | ` 19 | 20 | func preExecHook(c *Command) { 21 | if mousetrap.StartedByExplorer() { 22 | c.Print(MousetrapHelpText) 23 | time.Sleep(5 * time.Second) 24 | os.Exit(1) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/jwalterweatherman/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/jwalterweatherman/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Steve Francia 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. -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: go 4 | 5 | go: 6 | - 1.3 7 | - 1.4 8 | - 1.5 9 | - tip 10 | 11 | install: 12 | - go get github.com/golang/lint/golint 13 | - export PATH=$GOPATH/bin:$PATH 14 | - go install ./... 15 | 16 | script: 17 | - verify/all.sh 18 | - go test ./... 19 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/count.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- count Value 9 | type countValue int 10 | 11 | func newCountValue(val int, p *int) *countValue { 12 | *p = val 13 | return (*countValue)(p) 14 | } 15 | 16 | func (i *countValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | // -1 means that no specific value was passed, so increment 19 | if v == -1 { 20 | *i = countValue(*i + 1) 21 | } else { 22 | *i = countValue(v) 23 | } 24 | return err 25 | } 26 | 27 | func (i *countValue) Type() string { 28 | return "count" 29 | } 30 | 31 | func (i *countValue) String() string { return fmt.Sprintf("%v", *i) } 32 | 33 | func countConv(sval string) (interface{}, error) { 34 | i, err := strconv.Atoi(sval) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return i, nil 39 | } 40 | 41 | // GetCount return the int value of a flag with the given name 42 | func (f *FlagSet) GetCount(name string) (int, error) { 43 | val, err := f.getFlagType(name, "count", countConv) 44 | if err != nil { 45 | return 0, err 46 | } 47 | return val.(int), nil 48 | } 49 | 50 | // CountVar defines a count flag with specified name, default value, and usage string. 51 | // The argument p points to an int variable in which to store the value of the flag. 52 | // A count flag will add 1 to its value evey time it is found on the command line 53 | func (f *FlagSet) CountVar(p *int, name string, usage string) { 54 | f.CountVarP(p, name, "", usage) 55 | } 56 | 57 | // CountVarP is like CountVar only take a shorthand for the flag name. 58 | func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) { 59 | flag := f.VarPF(newCountValue(0, p), name, shorthand, usage) 60 | flag.NoOptDefVal = "-1" 61 | } 62 | 63 | // CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set 64 | func CountVar(p *int, name string, usage string) { 65 | CommandLine.CountVar(p, name, usage) 66 | } 67 | 68 | // CountVarP is like CountVar only take a shorthand for the flag name. 69 | func CountVarP(p *int, name, shorthand string, usage string) { 70 | CommandLine.CountVarP(p, name, shorthand, usage) 71 | } 72 | 73 | // Count defines a count flag with specified name, default value, and usage string. 74 | // The return value is the address of an int variable that stores the value of the flag. 75 | // A count flag will add 1 to its value evey time it is found on the command line 76 | func (f *FlagSet) Count(name string, usage string) *int { 77 | p := new(int) 78 | f.CountVarP(p, name, "", usage) 79 | return p 80 | } 81 | 82 | // CountP is like Count only takes a shorthand for the flag name. 83 | func (f *FlagSet) CountP(name, shorthand string, usage string) *int { 84 | p := new(int) 85 | f.CountVarP(p, name, shorthand, usage) 86 | return p 87 | } 88 | 89 | // Count like Count only the flag is placed on the CommandLine isntead of a given flag set 90 | func Count(name string, usage string) *int { 91 | return CommandLine.CountP(name, "", usage) 92 | } 93 | 94 | // CountP is like Count only takes a shorthand for the flag name. 95 | func CountP(name, shorthand string, usage string) *int { 96 | return CommandLine.CountP(name, shorthand, usage) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/golangflag.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 | package pflag 6 | 7 | import ( 8 | goflag "flag" 9 | "fmt" 10 | "reflect" 11 | "strings" 12 | ) 13 | 14 | var _ = fmt.Print 15 | 16 | // flagValueWrapper implements pflag.Value around a flag.Value. The main 17 | // difference here is the addition of the Type method that returns a string 18 | // name of the type. As this is generally unknown, we approximate that with 19 | // reflection. 20 | type flagValueWrapper struct { 21 | inner goflag.Value 22 | flagType string 23 | } 24 | 25 | // We are just copying the boolFlag interface out of goflag as that is what 26 | // they use to decide if a flag should get "true" when no arg is given. 27 | type goBoolFlag interface { 28 | goflag.Value 29 | IsBoolFlag() bool 30 | } 31 | 32 | func wrapFlagValue(v goflag.Value) Value { 33 | // If the flag.Value happens to also be a pflag.Value, just use it directly. 34 | if pv, ok := v.(Value); ok { 35 | return pv 36 | } 37 | 38 | pv := &flagValueWrapper{ 39 | inner: v, 40 | } 41 | 42 | t := reflect.TypeOf(v) 43 | if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr { 44 | t = t.Elem() 45 | } 46 | 47 | pv.flagType = strings.TrimSuffix(t.Name(), "Value") 48 | return pv 49 | } 50 | 51 | func (v *flagValueWrapper) String() string { 52 | return v.inner.String() 53 | } 54 | 55 | func (v *flagValueWrapper) Set(s string) error { 56 | return v.inner.Set(s) 57 | } 58 | 59 | func (v *flagValueWrapper) Type() string { 60 | return v.flagType 61 | } 62 | 63 | // PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag 64 | func PFlagFromGoFlag(goflag *goflag.Flag) *Flag { 65 | // Remember the default value as a string; it won't change. 66 | flag := &Flag{ 67 | Name: goflag.Name, 68 | Usage: goflag.Usage, 69 | Value: wrapFlagValue(goflag.Value), 70 | // Looks like golang flags don't set DefValue correctly :-( 71 | //DefValue: goflag.DefValue, 72 | DefValue: goflag.Value.String(), 73 | } 74 | if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() { 75 | flag.NoOptDefVal = "true" 76 | } 77 | return flag 78 | } 79 | 80 | // AddGoFlag will add the given *flag.Flag to the pflag.FlagSet 81 | func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) { 82 | if f.Lookup(goflag.Name) != nil { 83 | return 84 | } 85 | newflag := PFlagFromGoFlag(goflag) 86 | f.AddFlag(newflag) 87 | } 88 | 89 | // AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet 90 | func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) { 91 | if newSet == nil { 92 | return 93 | } 94 | newSet.VisitAll(func(goflag *goflag.Flag) { 95 | f.AddGoFlag(goflag) 96 | }) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int Value 9 | type intValue int 10 | 11 | func newIntValue(val int, p *int) *intValue { 12 | *p = val 13 | return (*intValue)(p) 14 | } 15 | 16 | func (i *intValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | *i = intValue(v) 19 | return err 20 | } 21 | 22 | func (i *intValue) Type() string { 23 | return "int" 24 | } 25 | 26 | func (i *intValue) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func intConv(sval string) (interface{}, error) { 29 | return strconv.Atoi(sval) 30 | } 31 | 32 | // GetInt return the int value of a flag with the given name 33 | func (f *FlagSet) GetInt(name string) (int, error) { 34 | val, err := f.getFlagType(name, "int", intConv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(int), nil 39 | } 40 | 41 | // IntVar defines an int flag with specified name, default value, and usage string. 42 | // The argument p points to an int variable in which to store the value of the flag. 43 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 44 | f.VarP(newIntValue(value, p), name, "", usage) 45 | } 46 | 47 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 49 | f.VarP(newIntValue(value, p), name, shorthand, usage) 50 | } 51 | 52 | // IntVar defines an int flag with specified name, default value, and usage string. 53 | // The argument p points to an int variable in which to store the value of the flag. 54 | func IntVar(p *int, name string, value int, usage string) { 55 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 56 | } 57 | 58 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 59 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 60 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Int defines an int flag with specified name, default value, and usage string. 64 | // The return value is the address of an int variable that stores the value of the flag. 65 | func (f *FlagSet) Int(name string, value int, usage string) *int { 66 | p := new(int) 67 | f.IntVarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 73 | p := new(int) 74 | f.IntVarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Int defines an int flag with specified name, default value, and usage string. 79 | // The return value is the address of an int variable that stores the value of the flag. 80 | func Int(name string, value int, usage string) *int { 81 | return CommandLine.IntP(name, "", value, usage) 82 | } 83 | 84 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 85 | func IntP(name, shorthand string, value int, usage string) *int { 86 | return CommandLine.IntP(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/string.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "fmt" 4 | 5 | // -- string Value 6 | type stringValue string 7 | 8 | func newStringValue(val string, p *string) *stringValue { 9 | *p = val 10 | return (*stringValue)(p) 11 | } 12 | 13 | func (s *stringValue) Set(val string) error { 14 | *s = stringValue(val) 15 | return nil 16 | } 17 | func (s *stringValue) Type() string { 18 | return "string" 19 | } 20 | 21 | func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) } 22 | 23 | func stringConv(sval string) (interface{}, error) { 24 | return sval, nil 25 | } 26 | 27 | // GetString return the string value of a flag with the given name 28 | func (f *FlagSet) GetString(name string) (string, error) { 29 | val, err := f.getFlagType(name, "string", stringConv) 30 | if err != nil { 31 | return "", err 32 | } 33 | return val.(string), nil 34 | } 35 | 36 | // StringVar defines a string flag with specified name, default value, and usage string. 37 | // The argument p points to a string variable in which to store the value of the flag. 38 | func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { 39 | f.VarP(newStringValue(value, p), name, "", usage) 40 | } 41 | 42 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 43 | func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { 44 | f.VarP(newStringValue(value, p), name, shorthand, usage) 45 | } 46 | 47 | // StringVar defines a string flag with specified name, default value, and usage string. 48 | // The argument p points to a string variable in which to store the value of the flag. 49 | func StringVar(p *string, name string, value string, usage string) { 50 | CommandLine.VarP(newStringValue(value, p), name, "", usage) 51 | } 52 | 53 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 54 | func StringVarP(p *string, name, shorthand string, value string, usage string) { 55 | CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) 56 | } 57 | 58 | // String defines a string flag with specified name, default value, and usage string. 59 | // The return value is the address of a string variable that stores the value of the flag. 60 | func (f *FlagSet) String(name string, value string, usage string) *string { 61 | p := new(string) 62 | f.StringVarP(p, name, "", value, usage) 63 | return p 64 | } 65 | 66 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 67 | func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { 68 | p := new(string) 69 | f.StringVarP(p, name, shorthand, value, usage) 70 | return p 71 | } 72 | 73 | // String defines a string flag with specified name, default value, and usage string. 74 | // The return value is the address of a string variable that stores the value of the flag. 75 | func String(name string, value string, usage string) *string { 76 | return CommandLine.StringP(name, "", value, usage) 77 | } 78 | 79 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 80 | func StringP(name, shorthand string, value string, usage string) *string { 81 | return CommandLine.StringP(name, shorthand, value, usage) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/viper/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/viper/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.4.3 4 | - 1.5.4 5 | - 1.6.2 6 | - tip 7 | 8 | os: 9 | - linux 10 | - osx 11 | 12 | matrix: 13 | allow_failures: 14 | - go: tip 15 | 16 | script: 17 | - go test -v ./... 18 | sudo: false 19 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/viper/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Steve Francia 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. -------------------------------------------------------------------------------- /vendor/github.com/spf13/viper/flags.go: -------------------------------------------------------------------------------- 1 | package viper 2 | 3 | import "github.com/spf13/pflag" 4 | 5 | // FlagValueSet is an interface that users can implement 6 | // to bind a set of flags to viper. 7 | type FlagValueSet interface { 8 | VisitAll(fn func(FlagValue)) 9 | } 10 | 11 | // FlagValue is an interface that users can implement 12 | // to bind different flags to viper. 13 | type FlagValue interface { 14 | HasChanged() bool 15 | Name() string 16 | ValueString() string 17 | ValueType() string 18 | } 19 | 20 | // pflagValueSet is a wrapper around *pflag.ValueSet 21 | // that implements FlagValueSet. 22 | type pflagValueSet struct { 23 | flags *pflag.FlagSet 24 | } 25 | 26 | // VisitAll iterates over all *pflag.Flag inside the *pflag.FlagSet. 27 | func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) { 28 | p.flags.VisitAll(func(flag *pflag.Flag) { 29 | fn(pflagValue{flag}) 30 | }) 31 | } 32 | 33 | // pflagValue is a wrapper aroung *pflag.flag 34 | // that implements FlagValue 35 | type pflagValue struct { 36 | flag *pflag.Flag 37 | } 38 | 39 | // HasChanges returns whether the flag has changes or not. 40 | func (p pflagValue) HasChanged() bool { 41 | return p.flag.Changed 42 | } 43 | 44 | // Name returns the name of the flag. 45 | func (p pflagValue) Name() string { 46 | return p.flag.Name 47 | } 48 | 49 | // ValueString returns the value of the flag as a string. 50 | func (p pflagValue) ValueString() string { 51 | return p.flag.Value.String() 52 | } 53 | 54 | // ValueType returns the type of the flag as a string. 55 | func (p pflagValue) ValueType() string { 56 | return p.flag.Value.Type() 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/viper/nohup.out: -------------------------------------------------------------------------------- 1 | QProcess::start: Process is already running 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_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-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 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 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | 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 <= 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 | -------------------------------------------------------------------------------- /vendor/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 | // use is a no-op, but the compiler cannot see that it is. 72 | // Calling use(p) ensures that p is kept live until that point. 73 | //go:noescape 74 | func use(p unsafe.Pointer) 75 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 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 = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int32, 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 = int32(sec) 40 | tv.Usec = int32(usec) 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint32(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint32(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 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 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/386 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 27 | 28 | func NsecToTimeval(nsec int64) (tv Timeval) { 29 | nsec += 999 // round up to microsecond 30 | tv.Usec = int32(nsec % 1e9 / 1e3) 31 | tv.Sec = int64(nsec / 1e9) 32 | return 33 | } 34 | 35 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 36 | func Gettimeofday(tv *Timeval) (err error) { 37 | // The tv passed to gettimeofday must be non-nil 38 | // but is otherwise unused. The answers come back 39 | // in the two registers. 40 | sec, usec, err := gettimeofday(tv) 41 | tv.Sec = sec 42 | tv.Usec = usec 43 | return err 44 | } 45 | 46 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 47 | k.Ident = uint64(fd) 48 | k.Filter = int16(mode) 49 | k.Flags = uint16(flags) 50 | } 51 | 52 | func (iov *Iovec) SetLen(length int) { 53 | iov.Len = uint64(length) 54 | } 55 | 56 | func (msghdr *Msghdr) SetControllen(length int) { 57 | msghdr.Controllen = uint32(length) 58 | } 59 | 60 | func (cmsg *Cmsghdr) SetLen(length int) { 61 | cmsg.Len = uint32(length) 62 | } 63 | 64 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 65 | var length = uint64(count) 66 | 67 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 68 | 69 | written = int(length) 70 | 71 | if e1 != 0 { 72 | err = e1 73 | } 74 | return 75 | } 76 | 77 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 78 | 79 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 80 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 81 | const SYS___SYSCTL = SYS_SYSCTL 82 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 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) // sic 74 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 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) // sic 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_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,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 = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 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 = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 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 = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 } 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 = nsec / 1e9 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = nsec % 1e9 / 1e3 24 | tv.Sec = nsec / 1e9 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/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 TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (cmsg *Cmsghdr) SetLen(length int) { 31 | cmsg.Len = uint32(length) 32 | } 33 | 34 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 35 | // TODO(aram): implement this, see issue 5847. 36 | panic("unimplemented") 37 | } 38 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | 9 | go_import_path: gopkg.in/yaml.v2 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | --------------------------------------------------------------------------------