├── .circleci └── config.yml ├── .gitignore ├── COPYING.LGPL-3 ├── LICENSE ├── Makefile ├── README.md ├── aggate-build ├── Dockerfile └── build.sh ├── cmd └── prom-aggregation-gateway │ ├── Dockerfile │ ├── main.go │ └── main_test.go ├── tools ├── .circleci │ └── config.yml ├── .gitignore ├── COPYING.LGPL-3 ├── LICENSE ├── README.md ├── bazel-rules │ ├── BUILD.bazel │ └── gogo.bzl ├── build │ ├── Makefile │ ├── golang │ │ ├── Dockerfile │ │ └── build.sh │ └── haskell │ │ ├── Dockerfile │ │ ├── build.sh │ │ └── copy-libraries ├── config_management │ ├── README.md │ ├── group_vars │ │ └── all │ ├── library │ │ └── setup_ansible_dependencies.yml │ ├── roles │ │ ├── dev-tools │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── docker-configuration │ │ │ ├── files │ │ │ │ └── docker.conf │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── docker-from-docker-ce-repo │ │ │ └── tasks │ │ │ │ ├── debian.yml │ │ │ │ ├── main.yml │ │ │ │ └── redhat.yml │ │ ├── docker-from-docker-repo │ │ │ └── tasks │ │ │ │ ├── debian.yml │ │ │ │ ├── main.yml │ │ │ │ └── redhat.yml │ │ ├── docker-from-get.docker.com │ │ │ └── tasks │ │ │ │ ├── debian.yml │ │ │ │ ├── main.yml │ │ │ │ └── redhat.yml │ │ ├── docker-from-tarball │ │ │ ├── tasks │ │ │ │ └── main.yml │ │ │ └── vars │ │ │ │ └── main.yml │ │ ├── docker-install │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── docker-prerequisites │ │ │ └── tasks │ │ │ │ ├── debian.yml │ │ │ │ └── main.yml │ │ ├── golang-from-tarball │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── kubelet-stop │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── kubernetes-docker-images │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── kubernetes-install │ │ │ └── tasks │ │ │ │ ├── debian.yml │ │ │ │ ├── main.yml │ │ │ │ └── redhat.yml │ │ ├── kubernetes-start │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── setup-ansible │ │ │ └── pre_tasks │ │ │ │ └── main.yml │ │ ├── setup-apt │ │ │ ├── files │ │ │ │ └── apt-daily.timer.conf │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── sock-shop │ │ │ └── tasks │ │ │ │ └── tasks.yml │ │ ├── weave-kube │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── weave-net-sources │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── weave-net-utilities │ │ │ └── tasks │ │ │ │ └── main.yml │ │ └── weave-net │ │ │ └── tasks │ │ │ └── main.yml │ ├── setup_bare_docker.yml │ ├── setup_weave-kube.yml │ ├── setup_weave-net_debug.yml │ ├── setup_weave-net_dev.yml │ └── setup_weave-net_test.yml ├── cover │ ├── Makefile │ ├── cover.go │ └── gather_coverage.sh ├── dependencies │ ├── cross_versions.py │ ├── list_os_images.sh │ └── list_versions.py ├── files-with-type ├── image-tag ├── integration │ ├── assert.sh │ ├── config.sh │ ├── gce.sh │ ├── run_all.sh │ └── sanity_check.sh ├── lint ├── provisioning │ ├── README.md │ ├── aws │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── do │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── gcp │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ └── setup.sh ├── publish-site ├── push-images ├── rebuild-image ├── runner │ ├── Makefile │ └── runner.go ├── sched ├── scheduler │ ├── .gitignore │ ├── README.md │ ├── app.yaml │ ├── appengine_config.py │ ├── cron.yaml │ ├── main.py │ └── requirements.txt ├── shell-lint ├── socks │ ├── Dockerfile │ ├── Makefile │ ├── README.md │ ├── connect.sh │ └── main.go └── test └── vendor ├── github.com ├── Sirupsen │ └── logrus │ │ ├── LICENSE │ │ ├── alt_exit.go │ │ ├── doc.go │ │ ├── entry.go │ │ ├── examples │ │ ├── basic │ │ │ └── basic.go │ │ └── hook │ │ │ └── hook.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── hooks │ │ ├── syslog │ │ │ └── syslog.go │ │ └── test │ │ │ └── test.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_appengine.go │ │ ├── terminal_bsd.go │ │ ├── terminal_linux.go │ │ ├── terminal_notwindows.go │ │ ├── terminal_solaris.go │ │ ├── terminal_windows.go │ │ ├── text_formatter.go │ │ └── writer.go ├── beorn7 │ └── perks │ │ └── quantile │ │ ├── LICENSE │ │ └── stream.go ├── golang │ └── protobuf │ │ ├── proto │ │ ├── LICENSE │ │ ├── clone.go │ │ ├── decode.go │ │ ├── encode.go │ │ ├── equal.go │ │ ├── extensions.go │ │ ├── lib.go │ │ ├── message_set.go │ │ ├── pointer_reflect.go │ │ ├── pointer_unsafe.go │ │ ├── properties.go │ │ ├── proto3_proto │ │ │ └── proto3.pb.go │ │ ├── text.go │ │ └── text_parser.go │ │ └── ptypes │ │ └── any │ │ ├── LICENSE │ │ └── any.pb.go ├── julienschmidt │ └── httprouter │ │ ├── LICENSE │ │ ├── path.go │ │ ├── router.go │ │ └── tree.go ├── matttproud │ └── golang_protobuf_extensions │ │ └── pbutil │ │ ├── LICENSE │ │ ├── decode.go │ │ ├── doc.go │ │ └── encode.go ├── pmezard │ └── go-difflib │ │ └── difflib │ │ ├── LICENSE │ │ └── difflib.go └── prometheus │ ├── client_golang │ └── prometheus │ │ ├── LICENSE │ │ ├── collector.go │ │ ├── counter.go │ │ ├── desc.go │ │ ├── doc.go │ │ ├── expvar_collector.go │ │ ├── fnv.go │ │ ├── gauge.go │ │ ├── go_collector.go │ │ ├── graphite │ │ └── bridge.go │ │ ├── histogram.go │ │ ├── http.go │ │ ├── metric.go │ │ ├── process_collector.go │ │ ├── promhttp │ │ └── http.go │ │ ├── push │ │ └── push.go │ │ ├── registry.go │ │ ├── summary.go │ │ ├── timer.go │ │ ├── untyped.go │ │ ├── value.go │ │ └── vec.go │ ├── client_model │ └── go │ │ ├── LICENSE │ │ └── metrics.pb.go │ ├── common │ ├── LICENSE │ ├── config │ │ ├── config.go │ │ └── tls_config.go │ ├── expfmt │ │ ├── decode.go │ │ ├── encode.go │ │ ├── expfmt.go │ │ ├── fuzz.go │ │ ├── text_create.go │ │ └── text_parse.go │ ├── internal │ │ └── bitbucket.org │ │ │ └── ww │ │ │ └── goautoneg │ │ │ └── autoneg.go │ ├── log │ │ ├── eventlog_formatter.go │ │ ├── log.go │ │ └── syslog_formatter.go │ ├── model │ │ ├── alert.go │ │ ├── fingerprinting.go │ │ ├── fnv.go │ │ ├── labels.go │ │ ├── labelset.go │ │ ├── metric.go │ │ ├── model.go │ │ ├── signature.go │ │ ├── silence.go │ │ ├── time.go │ │ └── value.go │ ├── route │ │ └── route.go │ └── version │ │ └── info.go │ └── procfs │ ├── LICENSE │ ├── doc.go │ ├── fs.go │ ├── ipvs.go │ ├── mdstat.go │ ├── mountstats.go │ ├── proc.go │ ├── proc_io.go │ ├── proc_limits.go │ ├── proc_stat.go │ └── stat.go ├── golang.org └── x │ ├── net │ └── context │ │ ├── LICENSE │ │ ├── context.go │ │ ├── ctxhttp │ │ ├── ctxhttp.go │ │ └── ctxhttp_pre17.go │ │ ├── go17.go │ │ └── pre_go17.go │ └── sys │ ├── unix │ ├── LICENSE │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── gccgo_linux_sparc64.go │ ├── mkpost.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.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 │ ├── syscall_unix_gc.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.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 │ └── windows │ ├── LICENSE │ ├── asm_windows_386.s │ ├── asm_windows_amd64.s │ ├── dll_windows.go │ ├── env_unset.go │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── mksyscall.go │ ├── race.go │ ├── race0.go │ ├── registry │ ├── key.go │ ├── mksyscall.go │ ├── syscall.go │ ├── value.go │ └── zsyscall_windows.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── svc │ ├── debug │ │ ├── log.go │ │ └── service.go │ ├── event.go │ ├── eventlog │ │ ├── install.go │ │ └── log.go │ ├── example │ │ ├── beep.go │ │ ├── install.go │ │ ├── main.go │ │ ├── manage.go │ │ └── service.go │ ├── go12.c │ ├── go12.go │ ├── go13.go │ ├── mgr │ │ ├── config.go │ │ ├── mgr.go │ │ └── service.go │ ├── security.go │ ├── service.go │ ├── sys_386.s │ └── sys_amd64.s │ ├── syscall.go │ ├── syscall_windows.go │ ├── zsyscall_windows.go │ ├── ztypes_windows.go │ ├── ztypes_windows_386.go │ └── ztypes_windows_amd64.go ├── gopkg.in ├── airbrake │ └── gobrake.v2 │ │ ├── LICENSE │ │ ├── gobrake.go │ │ ├── notice.go │ │ ├── notifier.go │ │ └── util.go └── gemnasium │ └── logrus-airbrake-hook.v2 │ ├── LICENSE │ └── airbrake.go └── manifest /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: /go/src/github.com/weaveworks/prom-aggregation-gateway 5 | docker: 6 | - image: weaveworks/build-golang:1.12.1-stretch 7 | steps: 8 | - checkout 9 | - setup_remote_docker 10 | 11 | - run: 12 | name: Install Docker client 13 | command: | 14 | set -x 15 | VER="17.03.0-ce" 16 | curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz 17 | tar -xz -C /tmp -f /tmp/docker-$VER.tgz 18 | mv /tmp/docker/* /usr/bin 19 | 20 | - run: make lint BUILD_IN_CONTAINER=false 21 | - run: make cmd/prom-aggregation-gateway/.uptodate BUILD_IN_CONTAINER=false 22 | 23 | - deploy: 24 | name: Push master image 25 | command: | 26 | if [ "${CIRCLE_BRANCH}" == "master" ]; then 27 | docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" 28 | docker push weaveworks/prom-aggregation-gateway:$(./tools/image-tag) 29 | docker push weaveworks/prom-aggregation-gateway:latest 30 | fi 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pkg 2 | .uptodate 3 | cmd/prom-aggregation-gateway/prom-aggregation-gateway -------------------------------------------------------------------------------- /aggate-build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM weaveworks/build-golang:1.12.1-stretch 2 | COPY build.sh / 3 | ENTRYPOINT ["/build.sh"] 4 | -------------------------------------------------------------------------------- /aggate-build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | SRC_PATH=$GOPATH/src/github.com/weaveworks/prom-aggregation-gateway 6 | 7 | # If we run make directly, any files created on the bind mount 8 | # will have awkward ownership. So we switch to a user with the 9 | # same user and group IDs as source directory. We have to set a 10 | # few things up so that sudo works without complaining later on. 11 | uid=$(stat --format="%u" "$SRC_PATH") 12 | gid=$(stat --format="%g" "$SRC_PATH") 13 | echo "weave:x:$uid:$gid::$SRC_PATH:/bin/sh" >>/etc/passwd 14 | echo "weave:*:::::::" >>/etc/shadow 15 | echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers 16 | 17 | su weave -c "PATH=$PATH make -C $SRC_PATH BUILD_IN_CONTAINER=false $*" 18 | -------------------------------------------------------------------------------- /cmd/prom-aggregation-gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.10 2 | COPY prom-aggregation-gateway / 3 | ENTRYPOINT ["/prom-aggregation-gateway"] 4 | -------------------------------------------------------------------------------- /tools/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | # Use 'machine' type so we can run the lint step with directory mounted 5 | machine: 6 | docker_layer_caching: true 7 | working_directory: /home/circleci/src/github.com/weaveworks/build-tools 8 | environment: 9 | GOPATH: /home/circleci/ 10 | steps: 11 | - checkout 12 | - run: cd build; make 13 | - run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c ./lint . 14 | - run: cd cover; make 15 | # Socks makefile needs to overwrite Go std library 16 | - run: sudo chmod a+wr --recursive /usr/local/go/pkg 17 | - run: cd socks; make 18 | - run: cd runner; make 19 | 20 | - deploy: 21 | command: | 22 | if [ "${CIRCLE_BRANCH}" == "master" ]; then 23 | cd build 24 | docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD 25 | for image in $(make images); do 26 | # Push all tags - latest and git-tag 27 | docker push "${image}" 28 | 29 | # Tag the built images with something derived from the base images in 30 | # their respective Dockerfiles. So "FROM golang:1.8.0-stretch" as a 31 | # base image would lead to a tag of "1.8.0-stretch" 32 | IMG_TAG=$(make "imagetag-${image#weaveworks/build-}") 33 | docker tag "${image}:latest" "${image}:${IMG_TAG}" 34 | docker push "${image}:${IMG_TAG}" 35 | done 36 | fi 37 | -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | cover/cover 2 | socks/proxy 3 | socks/image.tar 4 | runner/runner 5 | *.pyc 6 | *~ 7 | terraform.tfstate 8 | terraform.tfstate.backup 9 | *.retry 10 | build/**/.uptodate 11 | -------------------------------------------------------------------------------- /tools/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Weaveworks. All rights reserved. 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 | -------------------------------------------------------------------------------- /tools/bazel-rules/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") 2 | 3 | go_proto_compiler( 4 | name = "gogo_proto", 5 | deps = [ 6 | "//vendor/github.com/gogo/protobuf/gogoproto:go_default_library", 7 | "//vendor/github.com/gogo/protobuf/proto:go_default_library", 8 | "//vendor/github.com/gogo/protobuf/sortkeys:go_default_library", 9 | ], 10 | plugin = "@com_github_gogo_protobuf//protoc-gen-gogoslick", 11 | visibility = ["//visibility:public"], 12 | ) 13 | 14 | go_proto_compiler( 15 | name = "gogo_grpc", 16 | deps = [ 17 | "//vendor/github.com/gogo/protobuf/gogoproto:go_default_library", 18 | "//vendor/github.com/gogo/protobuf/proto:go_default_library", 19 | "//vendor/github.com/gogo/protobuf/sortkeys:go_default_library", 20 | "//vendor/google.golang.org/grpc:go_default_library", 21 | "//vendor/golang.org/x/net/context:go_default_library", 22 | ], 23 | plugin = "@com_github_gogo_protobuf//protoc-gen-gogoslick", 24 | options = ["plugins=grpc"], 25 | visibility = ["//visibility:public"], 26 | ) 27 | -------------------------------------------------------------------------------- /tools/bazel-rules/gogo.bzl: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_repository") 2 | 3 | 4 | _BUILD_FILE = """ 5 | proto_library( 6 | name = "gogoproto", 7 | srcs = ["gogo.proto"], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | ], 11 | visibility = ["//visibility:public"], 12 | ) 13 | """ 14 | 15 | def _go_repository_impl(ctx): 16 | ctx.file("BUILD.bazel", content="") 17 | ctx.file("github.com/gogo/protobuf/gogoproto/BUILD.bazel", content=_BUILD_FILE) 18 | ctx.template("github.com/gogo/protobuf/gogoproto/gogo.proto", ctx.attr._proto) 19 | 20 | _gogo_proto_repository = repository_rule( 21 | implementation = _go_repository_impl, 22 | attrs = { 23 | "_proto": attr.label(default="//vendor/github.com/gogo/protobuf/gogoproto:gogo.proto"), 24 | }, 25 | ) 26 | 27 | def gogo_dependencies(): 28 | go_repository( 29 | name = "com_github_gogo_protobuf", 30 | importpath = "github.com/gogo/protobuf", 31 | urls = ["https://codeload.github.com/ianthehat/protobuf/zip/2adc21fd136931e0388e278825291678e1d98309"], 32 | strip_prefix = "protobuf-2adc21fd136931e0388e278825291678e1d98309", 33 | type = "zip", 34 | build_file_proto_mode="disable", 35 | ) 36 | _gogo_proto_repository(name = "internal_gogo_proto_repository") 37 | -------------------------------------------------------------------------------- /tools/build/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean images 2 | .DEFAULT_GOAL := all 3 | 4 | # Boiler plate for bulding Docker containers. 5 | # All this must go at top of file I'm afraid. 6 | IMAGE_PREFIX := weaveworks/build- 7 | IMAGE_TAG := $(shell ../image-tag) 8 | GIT_REVISION := $(shell git rev-parse HEAD) 9 | UPTODATE := .uptodate 10 | 11 | # Every directory with a Dockerfile in it builds an image called 12 | # $(IMAGE_PREFIX). Dependencies (i.e. things that go in the image) 13 | # still need to be explicitly declared. 14 | %/$(UPTODATE): %/Dockerfile %/* 15 | $(SUDO) docker build --build-arg=revision=$(GIT_REVISION) -t $(IMAGE_PREFIX)$(shell basename $(@D)) $(@D)/ 16 | $(SUDO) docker tag $(IMAGE_PREFIX)$(shell basename $(@D)) $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG) 17 | touch $@ 18 | 19 | # Get a list of directories containing Dockerfiles 20 | DOCKERFILES := $(shell find . -name tools -prune -o -name vendor -prune -o -type f -name 'Dockerfile' -print) 21 | UPTODATE_FILES := $(patsubst %/Dockerfile,%/$(UPTODATE),$(DOCKERFILES)) 22 | DOCKER_IMAGE_DIRS := $(patsubst %/Dockerfile,%,$(DOCKERFILES)) 23 | IMAGE_NAMES := $(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)%,$(shell basename $(dir)))) 24 | images: 25 | $(info $(IMAGE_NAMES)) 26 | @echo > /dev/null 27 | 28 | # Define imagetag-golang, etc, for each image, which parses the dockerfile and 29 | # prints an image tag. For example: 30 | # FROM golang:1.8.1-stretch 31 | # in the "foo/Dockerfile" becomes: 32 | # $ make imagetag-foo 33 | # 1.8.1-stretch 34 | define imagetag_dep 35 | .PHONY: imagetag-$(1) 36 | $(patsubst $(IMAGE_PREFIX)%,imagetag-%,$(1)): $(patsubst $(IMAGE_PREFIX)%,%,$(1))/Dockerfile 37 | @cat $$< | grep "^FROM " | head -n1 | sed 's/FROM \(.*\):\(.*\)/\2/' 38 | endef 39 | $(foreach image, $(IMAGE_NAMES), $(eval $(call imagetag_dep, $(image)))) 40 | 41 | all: $(UPTODATE_FILES) 42 | 43 | clean: 44 | $(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true 45 | rm -rf $(UPTODATE_FILES) 46 | 47 | 48 | -------------------------------------------------------------------------------- /tools/build/golang/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.12.1-stretch 2 | RUN apt-get update && \ 3 | apt-get install -y \ 4 | curl \ 5 | file \ 6 | git \ 7 | jq \ 8 | libprotobuf-dev \ 9 | make \ 10 | protobuf-compiler \ 11 | python-pip \ 12 | python-requests \ 13 | python-yaml \ 14 | shellcheck \ 15 | unzip && \ 16 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 17 | RUN pip install attrs pyhcl yapf==0.16.2 flake8==3.3.0 18 | RUN curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \ 19 | echo "b1925c2c405458811f0c227266402cf1868b4de529f114722c2e3a5af4ac7bb2 shfmt" | sha256sum -c && \ 20 | chmod +x shfmt && \ 21 | mv shfmt /usr/bin 22 | RUN go clean -i net && \ 23 | go install -tags netgo std && \ 24 | go install -race -tags netgo std 25 | RUN go get -tags netgo \ 26 | github.com/FiloSottile/gvt \ 27 | github.com/client9/misspell/cmd/misspell \ 28 | github.com/fatih/hclfmt \ 29 | github.com/fzipp/gocyclo \ 30 | github.com/gogo/protobuf/gogoproto \ 31 | github.com/gogo/protobuf/protoc-gen-gogoslick \ 32 | github.com/golang/dep/... \ 33 | golang.org/x/lint/golint \ 34 | github.com/golang/protobuf/protoc-gen-go \ 35 | github.com/kisielk/errcheck \ 36 | github.com/mjibson/esc \ 37 | github.com/prometheus/prometheus/cmd/promtool && \ 38 | rm -rf /go/pkg /go/src 39 | RUN mkdir protoc && \ 40 | cd protoc && \ 41 | curl -O -L https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip && \ 42 | unzip protoc-3.1.0-linux-x86_64.zip && \ 43 | cp bin/protoc /usr/bin/ && \ 44 | chmod o+x /usr/bin/protoc && \ 45 | cd .. && \ 46 | rm -rf protoc 47 | RUN mkdir -p /var/run/secrets/kubernetes.io/serviceaccount && \ 48 | touch /var/run/secrets/kubernetes.io/serviceaccount/token 49 | COPY build.sh / 50 | ENTRYPOINT ["/build.sh"] 51 | 52 | ARG revision 53 | LABEL maintainer="Weaveworks " \ 54 | org.opencontainers.image.title="golang" \ 55 | org.opencontainers.image.source="https://github.com/weaveworks/build-tools/tree/master/build/golang" \ 56 | org.opencontainers.image.revision="${revision}" \ 57 | org.opencontainers.image.vendor="Weaveworks" 58 | -------------------------------------------------------------------------------- /tools/build/golang/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | if [ -n "${SRC_NAME:-}" ]; then 6 | SRC_PATH=${SRC_PATH:-$GOPATH/src/$SRC_NAME} 7 | elif [ -z "${SRC_PATH:-}" ]; then 8 | echo "Must set either \$SRC_NAME or \$SRC_PATH." 9 | exit 1 10 | fi 11 | 12 | # If we run make directly, any files created on the bind mount 13 | # will have awkward ownership. So we switch to a user with the 14 | # same user and group IDs as source directory. We have to set a 15 | # few things up so that sudo works without complaining later on. 16 | uid=$(stat --format="%u" "$SRC_PATH") 17 | gid=$(stat --format="%g" "$SRC_PATH") 18 | echo "weave:x:$uid:$gid::$SRC_PATH:/bin/sh" >>/etc/passwd 19 | echo "weave:*:::::::" >>/etc/shadow 20 | echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers 21 | 22 | su weave -c "PATH=$PATH make -C $SRC_PATH BUILD_IN_CONTAINER=false $*" 23 | -------------------------------------------------------------------------------- /tools/build/haskell/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fpco/stack-build:lts-8.9 2 | COPY build.sh / 3 | COPY copy-libraries /usr/local/bin/ 4 | ENTRYPOINT ["/build.sh"] 5 | 6 | ARG revision 7 | LABEL maintainer="Weaveworks " \ 8 | org.opencontainers.image.title="haskell" \ 9 | org.opencontainers.image.source="https://github.com/weaveworks/build-tools/tree/master/build/haskell" \ 10 | org.opencontainers.image.revision="${revision}" \ 11 | org.opencontainers.image.vendor="Weaveworks" 12 | -------------------------------------------------------------------------------- /tools/build/haskell/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Build a static Haskell binary using stack. 4 | 5 | set -eu 6 | 7 | if [ -z "${SRC_PATH:-}" ]; then 8 | echo "Must set \$SRC_PATH." 9 | exit 1 10 | fi 11 | 12 | make -C "$SRC_PATH" BUILD_IN_CONTAINER=false "$@" 13 | -------------------------------------------------------------------------------- /tools/build/haskell/copy-libraries: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copy dynamically linked libraries for a binary, so we can assemble a Docker 4 | # image. 5 | # 6 | # Run with: 7 | # copy-libraries /path/to/binary /output/dir 8 | # 9 | # Dependencies: 10 | # - awk 11 | # - cp 12 | # - grep 13 | # - ldd 14 | # - mkdir 15 | 16 | set -o errexit 17 | set -o nounset 18 | set -o pipefail 19 | 20 | # Path to a Linux binary that we're going to run in the container. 21 | binary_path="${1}" 22 | # Path to directory to write the output to. 23 | output_dir="${2}" 24 | 25 | exe_name=$(basename "${binary_path}") 26 | 27 | # Identify linked libraries. 28 | libraries=($(ldd "${binary_path}" | awk '{print $(NF-1)}' | grep -v '=>')) 29 | # Add /bin/sh, which we need for Docker imports. 30 | libraries+=('/bin/sh') 31 | 32 | mkdir -p "${output_dir}" 33 | 34 | # Copy executable and all needed libraries into temporary directory. 35 | cp "${binary_path}" "${output_dir}/${exe_name}" 36 | for lib in "${libraries[@]}"; do 37 | mkdir -p "${output_dir}/$(dirname "$lib")" 38 | # Need -L to make sure we get actual libraries & binaries, not symlinks to 39 | # them. 40 | cp -L "${lib}" "${output_dir}/${lib}" 41 | done 42 | -------------------------------------------------------------------------------- /tools/config_management/group_vars/all: -------------------------------------------------------------------------------- 1 | --- 2 | go_version: 1.8.1 3 | terraform_version: 0.8.5 4 | docker_version: 17.06 5 | docker_install_role: 'docker-from-docker-ce-repo' 6 | kubernetes_version: 1.6.1 7 | kubernetes_cni_version: 0.5.1 8 | kubernetes_token: '123456.0123456789123456' 9 | etcd_container_version: 2.2.5 10 | kube_discovery_container_version: 1.0 11 | pause_container_version: 3.0 12 | -------------------------------------------------------------------------------- /tools/config_management/library/setup_ansible_dependencies.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Ansible's dependencies: python and lsb_release, required respectively 4 | # to run Ansible modules and gather Ansible facts. 5 | # 6 | # See also: 7 | # - http://docs.ansible.com/ansible/intro_installation.html#managed-node-requirements 8 | # - http://docs.ansible.com/ansible/setup_module.html 9 | ################################################################################ 10 | 11 | - name: check if python is installed (as required by ansible modules) 12 | raw: test -e /usr/bin/python 13 | register: is_python_installed 14 | failed_when: is_python_installed.rc not in [0, 1] 15 | changed_when: false # never mutates state. 16 | 17 | - name: install python if missing (as required by ansible modules) 18 | when: is_python_installed|failed # skip otherwise 19 | raw: (test -e /usr/bin/apt-get && apt-get update && apt-get install -y python-minimal) || (test -e /usr/bin/yum && yum update && yum install -y python) 20 | changed_when: is_python_installed.rc == 1 21 | 22 | - name: check if lsb_release is installed (as required for ansible facts) 23 | raw: test -e /usr/bin/lsb_release 24 | register: is_lsb_release_installed 25 | failed_when: is_lsb_release_installed.rc not in [0, 1] 26 | changed_when: false # never mutates state. 27 | 28 | - name: install lsb_release if missing (as required for ansible facts) 29 | when: is_lsb_release_installed|failed # skip otherwise 30 | raw: (test -e /usr/bin/apt-get && apt-get install -y lsb_release) || (test -e /usr/bin/yum && yum install -y redhat-lsb-core) 31 | changed_when: is_lsb_release_installed.rc == 1 32 | 33 | - setup: # gather 'facts', i.e. compensates for 'gather_facts: false' in calling playbook. 34 | -------------------------------------------------------------------------------- /tools/config_management/roles/dev-tools/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Development Environment. 3 | 4 | - name: install development tools 5 | package: 6 | name: "{{ item }}" 7 | state: present 8 | with_items: 9 | # weave net dependencies 10 | - make 11 | - vagrant 12 | # ansible dependencies 13 | - python-pip 14 | - python-dev 15 | - libffi-dev 16 | - libssl-dev 17 | # terraform dependencies 18 | - unzip 19 | # other potentially useful tools: 20 | - aufs-tools 21 | - ethtool 22 | - iputils-arping 23 | - libpcap-dev 24 | - git 25 | - mercurial 26 | - bc 27 | - jq 28 | 29 | - name: install ansible 30 | pip: 31 | name: ansible 32 | state: present 33 | 34 | - name: install terraform 35 | unarchive: 36 | src: 'https://releases.hashicorp.com/terraform/{{ terraform_version }}/terraform_{{ terraform_version }}_linux_{{ {"x86_64": "amd64", "i386": "386"}[ansible_architecture] }}.zip' 37 | remote_src: yes 38 | dest: /usr/bin 39 | mode: 0555 40 | creates: /usr/bin/terraform 41 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-configuration/files/docker.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart= 3 | ExecStart=/usr/bin/dockerd -H fd:// -H unix:///var/run/alt-docker.sock -H tcp://0.0.0.0:2375 -s overlay --insecure-registry "weave-ci-registry:5000" 4 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-configuration/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Configure Docker 3 | # See also: https://docs.docker.com/engine/installation/linux/ubuntulinux/#install 4 | 5 | - name: ensure docker group is present (or create it) 6 | group: 7 | name: docker 8 | state: present 9 | 10 | - name: add user to docker group (avoids sudo-ing) 11 | user: 12 | name: "{{ ansible_user }}" 13 | group: docker 14 | state: present 15 | 16 | - name: ensure docker's systemd directory exists 17 | file: 18 | path: /etc/systemd/system/docker.service.d 19 | state: directory 20 | recurse: yes 21 | when: ansible_os_family != "RedHat" 22 | 23 | - name: enable docker remote api over tcp 24 | copy: 25 | src: "{{ role_path }}/files/docker.conf" 26 | dest: /etc/systemd/system/docker.service.d/docker.conf 27 | register: docker_conf 28 | when: ansible_os_family != "RedHat" 29 | 30 | - name: restart docker service 31 | systemd: 32 | name: docker 33 | state: restarted 34 | daemon_reload: yes # ensure docker.conf is picked up. 35 | enabled: yes 36 | when: docker_conf.changed or ansible_os_family == "RedHat" 37 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-ce-repo/tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Debian / Ubuntu specific: 3 | 4 | - name: install dependencies for docker repository 5 | package: 6 | name: "{{ item }}" 7 | state: present 8 | with_items: 9 | - apt-transport-https 10 | - ca-certificates 11 | 12 | - name: add apt key for the docker repository 13 | apt_key: 14 | keyserver: hkp://ha.pool.sks-keyservers.net:80 15 | id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 16 | state: present 17 | register: apt_key_docker_repo 18 | 19 | - name: add docker's apt repository ({{ ansible_distribution | lower }}-{{ ansible_distribution_release }}) 20 | apt_repository: 21 | repo: deb https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename|lower }} stable 22 | state: present 23 | register: apt_docker_repo 24 | 25 | - name: update apt's cache 26 | apt: 27 | update_cache: yes 28 | when: apt_key_docker_repo.changed or apt_docker_repo.changed 29 | 30 | - name: install docker-engine 31 | package: 32 | name: "{{ item }}" 33 | state: present 34 | with_items: 35 | - docker-ce={{ docker_version }}* 36 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-ce-repo/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Docker 3 | # See also: https://docs.docker.com/engine/installation/linux/ubuntulinux/#install 4 | 5 | # Distribution-specific tasks: 6 | - include: debian.yml 7 | when: ansible_os_family == "Debian" 8 | 9 | - include: redhat.yml 10 | when: ansible_os_family == "RedHat" 11 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-ce-repo/tasks/redhat.yml: -------------------------------------------------------------------------------- 1 | # Docker installation from Docker's CentOS Community Edition 2 | # See also: https://docs.docker.com/engine/installation/linux/centos/ 3 | 4 | - name: remove all potentially pre existing packages 5 | yum: 6 | name: '{{ item }}' 7 | state: absent 8 | with_items: 9 | - docker 10 | - docker-common 11 | - container-selinux 12 | - docker-selinux 13 | - docker-engine 14 | 15 | - name: install yum-utils 16 | yum: 17 | name: yum-utils 18 | state: present 19 | 20 | - name: add docker ce repo 21 | command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 22 | 23 | # Note that Docker CE versions do not follow regular Docker versions, but look 24 | # like, for example: "17.03.0.el7" 25 | - name: install docker 26 | yum: 27 | name: 'docker-ce-{{ docker_version }}' 28 | update_cache: yes 29 | state: present 30 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-repo/tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Debian / Ubuntu specific: 3 | 4 | - name: install dependencies for docker repository 5 | package: 6 | name: "{{ item }}" 7 | state: present 8 | with_items: 9 | - apt-transport-https 10 | - ca-certificates 11 | 12 | - name: add apt key for the docker repository 13 | apt_key: 14 | keyserver: hkp://ha.pool.sks-keyservers.net:80 15 | id: 58118E89F3A912897C070ADBF76221572C52609D 16 | state: present 17 | register: apt_key_docker_repo 18 | 19 | - name: add docker's apt repository ({{ ansible_distribution | lower }}-{{ ansible_distribution_release }}) 20 | apt_repository: 21 | repo: deb https://apt.dockerproject.org/repo {{ ansible_distribution | lower }}-{{ ansible_distribution_release }} main 22 | state: present 23 | register: apt_docker_repo 24 | 25 | - name: update apt's cache 26 | apt: 27 | update_cache: yes 28 | when: apt_key_docker_repo.changed or apt_docker_repo.changed 29 | 30 | - name: install docker-engine 31 | package: 32 | name: "{{ item }}" 33 | state: present 34 | with_items: 35 | - docker-engine={{ docker_version }}* 36 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-repo/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Docker 3 | # See also: https://docs.docker.com/engine/installation/linux/ubuntulinux/#install 4 | 5 | # Distribution-specific tasks: 6 | - include: debian.yml 7 | when: ansible_os_family == "Debian" 8 | 9 | - include: redhat.yml 10 | when: ansible_os_family == "RedHat" 11 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-docker-repo/tasks/redhat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # RedHat / CentOS specific: 3 | 4 | - name: add docker' yum repository (centos/{{ ansible_lsb.major_release }}) 5 | yum_repository: 6 | name: docker 7 | description: Docker YUM repo 8 | file: external_repos 9 | baseurl: https://yum.dockerproject.org/repo/main/centos/{{ ansible_lsb.major_release }} 10 | enabled: yes 11 | gpgkey: https://yum.dockerproject.org/gpg 12 | gpgcheck: yes 13 | state: present 14 | 15 | - name: update yum's cache 16 | yum: 17 | name: "*" 18 | update_cache: yes 19 | 20 | - name: install docker-engine 21 | package: 22 | name: "{{ item }}" 23 | state: present 24 | with_items: 25 | - docker-engine-{{ docker_version }} 26 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-get.docker.com/tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Debian / Ubuntu specific: 3 | 4 | - name: apt-import gpg key for the docker repository 5 | shell: curl -sSL https://get.docker.com/gpg | sudo apt-key add - 6 | 7 | - name: install docker 8 | shell: 'curl -sSL https://get.docker.com/ | sed -e s/docker-engine/docker-engine={{ docker_version }}*/ -e s/docker-ce/docker-ce={{ docker_version }}*/ | sh' 9 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-get.docker.com/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Docker 3 | # See also: legacy gce.sh script 4 | 5 | # Distribution-specific tasks: 6 | - include: debian.yml 7 | when: ansible_os_family == "Debian" 8 | 9 | - include: redhat.yml 10 | when: ansible_os_family == "RedHat" 11 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-get.docker.com/tasks/redhat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # RedHat / CentOS specific: 3 | 4 | - name: rpm-import gpg key for the docker repository 5 | shell: curl -sSLo /tmp/docker.gpg https://get.docker.com/gpg && sudo rpm --import /tmp/docker.gpg 6 | 7 | - name: install docker 8 | shell: 'curl -sSL https://get.docker.com/ | sed -e s/docker-engine/docker-engine-{{ docker_version }}*/ | sh' 9 | 10 | - name: wait for docker installation to complete 11 | shell: yum install -y yum-utils && yum-complete-transaction 12 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-tarball/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Docker 3 | # See also: 4 | # - https://docs.docker.com/engine/installation/linux/ubuntulinux/#install 5 | # - https://github.com/docker/docker/releases 6 | 7 | - include_role: 8 | name: docker-prerequisites 9 | 10 | - name: install daemon 11 | package: 12 | name: daemon 13 | state: present 14 | 15 | - name: 'create directory {{ docker_dir }}/{{ docker_version }}' 16 | file: 17 | path: '{{ docker_dir }}/{{ docker_version }}' 18 | state: directory 19 | mode: 0755 20 | 21 | - name: download and extract docker 22 | unarchive: 23 | src: 'https://get.docker.com/builds/Linux/x86_64/docker-{{ docker_version }}.tgz' 24 | remote_src: yes 25 | dest: '{{ docker_dir }}/{{ docker_version }}' 26 | extra_opts: '--strip-components=1' 27 | mode: 0555 28 | creates: '{{ docker_dir }}/{{ docker_version }}/docker' 29 | 30 | - name: create symlink to current version 31 | file: 32 | src: '{{ docker_dir }}/{{ docker_version }}' 33 | dest: '{{ docker_dir }}/current' 34 | state: link 35 | mode: 0555 36 | 37 | - name: list all files to symlink 38 | find: 39 | paths: '{{ docker_dir }}/current' 40 | file_type: file 41 | register: binaries 42 | changed_when: false 43 | 44 | - name: create symlinks to all binaries 45 | file: 46 | src: '{{ item }}' 47 | dest: /usr/bin/{{ item | basename }} 48 | state: link 49 | with_items: "{{ binaries.files | map(attribute='path') | list }}" 50 | 51 | - name: killall docker 52 | command: killall docker 53 | register: killall 54 | failed_when: false 55 | changed_when: killall.rc == 0 56 | 57 | - name: start dockerd 58 | command: daemon -- /usr/bin/dockerd 59 | 60 | - include_role: 61 | name: docker-configuration 62 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-from-tarball/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | docker_dir: '/opt/docker' 3 | docker_url: '{{ "rc" in {{ docker_version }} | ternary( > 4 | "https://test.docker.com/builds/Linux/x86_64/docker-{{ docker_version }}.tgz", > 5 | "https://get.docker.com/builds/Linux/x86_64/docker-{{ docker_version }}.tgz") }}' 6 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-install/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Docker 3 | 4 | - include_role: 5 | name: docker-prerequisites 6 | 7 | # Dynamically include docker installation role using 'when' as Ansible does not 8 | # allow for include_role's name to be set to a variable. Indeed: 9 | # - include_role: 10 | # name: '{{ docker_install_role }}' 11 | # fails with: 12 | # ERROR! 'docker_install_role' is undefined 13 | - include_role: 14 | name: docker-from-docker-repo 15 | when: docker_install_role == 'docker-from-docker-repo' 16 | 17 | - include_role: 18 | name: docker-from-docker-ce-repo 19 | when: docker_install_role == 'docker-from-docker-ce-repo' 20 | 21 | - include_role: 22 | name: docker-from-get.docker.com 23 | when: docker_install_role == 'docker-from-get.docker.com' 24 | 25 | - include_role: 26 | name: docker-from-tarball 27 | when: docker_install_role == 'docker-from-tarball' 28 | 29 | - include_role: 30 | name: docker-configuration 31 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-prerequisites/tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install Docker's dependencies 3 | # See also: https://docs.docker.com/engine/installation/linux/ubuntulinux/#install 4 | 5 | - name: install linux-image-extra-*/virtual 6 | package: 7 | name: "{{ item }}" 8 | state: present 9 | with_items: 10 | - linux-image-extra-{{ ansible_kernel }} 11 | - linux-image-extra-virtual 12 | -------------------------------------------------------------------------------- /tools/config_management/roles/docker-prerequisites/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Distribution-specific tasks: 4 | - include: debian.yml 5 | when: ansible_os_family == "Debian" 6 | -------------------------------------------------------------------------------- /tools/config_management/roles/golang-from-tarball/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Go. 3 | 4 | - name: install go 5 | unarchive: 6 | src: 'https://storage.googleapis.com/golang/go{{ go_version }}.linux-{{ {"x86_64": "amd64", "i386": "386"}[ansible_architecture] }}.tar.gz' 7 | remote_src: yes 8 | dest: /usr/local 9 | mode: 0777 10 | creates: /usr/local/go/bin/go 11 | 12 | - name: set go env. vars. and add go to path 13 | blockinfile: 14 | dest: '$HOME/.bashrc' 15 | block: | 16 | export PATH=$PATH:/usr/local/go/bin 17 | export GOPATH=$HOME 18 | state: present 19 | create: yes 20 | mode: 0644 21 | become: '{{ item }}' 22 | with_items: 23 | - true # Run as root 24 | - false # Run as SSH user 25 | 26 | - name: source ~/.bashrc from ~/.bash_profile 27 | lineinfile: 28 | dest: '$HOME/.bash_profile' 29 | line: '[ -r $HOME/.bashrc ] && source $HOME/.bashrc' 30 | state: present 31 | create: yes 32 | mode: 0644 33 | become: '{{ item }}' 34 | with_items: 35 | - true # Run as root 36 | - false # Run as SSH user 37 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubelet-stop/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: check if kubelet service exists 4 | stat: 5 | path: /etc/init.d/kubelet 6 | register: kubelet 7 | 8 | # avoids having weave-net and weave-kube conflict in some test cases (e.g. 130_expose_test.sh) 9 | - name: stop kubelet service 10 | systemd: 11 | name: kubelet 12 | state: stopped 13 | enabled: no 14 | when: kubelet.stat.exists 15 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubernetes-docker-images/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: docker pull images used by k8s tests 4 | docker_image: 5 | name: '{{ item }}' 6 | state: present 7 | with_items: 8 | - gcr.io/google_containers/etcd-amd64:{{ etcd_container_version }} 9 | - gcr.io/google_containers/kube-apiserver-amd64:v{{ kubernetes_version }} 10 | - gcr.io/google_containers/kube-controller-manager-amd64:v{{ kubernetes_version }} 11 | - gcr.io/google_containers/kube-proxy-amd64:v{{ kubernetes_version }} 12 | - gcr.io/google_containers/kube-scheduler-amd64:v{{ kubernetes_version }} 13 | - gcr.io/google_containers/kube-discovery-amd64:{{ kube_discovery_container_version }} 14 | - gcr.io/google_containers/pause-amd64:{{ pause_container_version }} 15 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubernetes-install/tasks/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Debian / Ubuntu specific: 3 | 4 | - name: add apt key for the kubernetes repository 5 | apt_key: 6 | url: https://packages.cloud.google.com/apt/doc/apt-key.gpg 7 | state: present 8 | register: apt_key_k8s_repo 9 | 10 | - name: add kubernetes' apt repository (kubernetes-{{ ansible_distribution_release }}) 11 | apt_repository: 12 | repo: deb http://apt.kubernetes.io/ kubernetes-{{ ansible_distribution_release }} main 13 | state: present 14 | register: apt_k8s_repo 15 | when: '"alpha" not in kubernetes_version and "beta" not in kubernetes_version' 16 | 17 | - name: add kubernetes' apt repository (kubernetes-{{ ansible_distribution_release }}-unstable) 18 | apt_repository: 19 | repo: deb http://apt.kubernetes.io/ kubernetes-{{ ansible_distribution_release }}-unstable main 20 | state: present 21 | register: apt_k8s_repo 22 | when: '"alpha" in kubernetes_version or "beta" in kubernetes_version' 23 | 24 | - name: update apt's cache 25 | apt: 26 | update_cache: yes 27 | when: apt_key_k8s_repo.changed or apt_k8s_repo.changed 28 | 29 | - name: install kubelet and kubectl 30 | package: 31 | name: "{{ item }}" 32 | state: present 33 | with_items: 34 | - kubelet={{ kubernetes_version }}* 35 | - kubectl={{ kubernetes_version }}* 36 | - kubeadm={{ kubernetes_version }}* 37 | - kubernetes-cni={{ kubernetes_cni_version }}* 38 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubernetes-install/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install Kubernetes 3 | 4 | # Distribution-specific tasks: 5 | - include: debian.yml 6 | when: ansible_os_family == "Debian" 7 | 8 | - include: redhat.yml 9 | when: ansible_os_family == "RedHat" 10 | 11 | - name: install ebtables 12 | package: 13 | name: "{{ item }}" 14 | state: present 15 | with_items: 16 | - ebtables 17 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubernetes-install/tasks/redhat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # RedHat / CentOS specific: 3 | 4 | - name: add kubernetes' yum repository (kubernetes-el{{ ansible_lsb.major_release }}-x86-64) 5 | yum_repository: 6 | name: kubernetes 7 | description: Kubernetes YUM repo 8 | file: external_repos 9 | baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el{{ ansible_lsb.major_release }}-x86_64 10 | enabled: yes 11 | gpgkey: https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg 12 | gpgcheck: yes 13 | state: present 14 | register: yum_k8s_repo 15 | 16 | - name: update yum's cache 17 | yum: 18 | name: "*" 19 | update_cache: yes 20 | when: yum_k8s_repo.changed 21 | 22 | - name: install kubelet and kubectl 23 | package: 24 | name: "{{ item }}" 25 | state: present 26 | with_items: 27 | - kubelet-{{ kubernetes_version }}* 28 | - kubectl-{{ kubernetes_version }}* 29 | - kubeadm-{{ kubernetes_version }}* 30 | - kubernetes-cni-{{ kubernetes_cni_version }}* 31 | -------------------------------------------------------------------------------- /tools/config_management/roles/kubernetes-start/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Start Kubernetes 3 | 4 | - name: kubeadm reset 5 | command: kubeadm reset 6 | 7 | - name: restart kubelet service 8 | systemd: 9 | name: kubelet 10 | state: restarted 11 | enabled: yes 12 | 13 | - name: optionally set kubeconfig option 14 | set_fact: 15 | kubeconfig: '{{ (kubernetes_version >= "1.5.4") | ternary("--kubeconfig /etc/kubernetes/admin.conf", "") }}' 16 | kubernetes_version_option: '{{ (kubernetes_version >= "1.6") | ternary("kubernetes_version", "use-kubernetes-version") }}' 17 | 18 | - name: kubeadm init on the master 19 | command: 'kubeadm init --{{ kubernetes_version_option }}=v{{ kubernetes_version }} --token={{ kubernetes_token }}' 20 | when: ' {{ play_hosts[0] == inventory_hostname }}' 21 | 22 | - name: allow pods to be run on the master (if only node) 23 | command: 'kubectl {{ kubeconfig }} taint nodes --all {{ (kubernetes_version < "1.6") | ternary("dedicated-", "node-role.kubernetes.io/master:NoSchedule-") }}' 24 | when: '{{ play_hosts | length }} == 1' 25 | 26 | - name: kubeadm join on workers 27 | command: 'kubeadm join --token={{ kubernetes_token }} {{ hostvars[play_hosts[0]].private_ip }}{{ (kubernetes_version > "1.6") | ternary(":6443", "") }}' 28 | when: ' {{ play_hosts[0] != inventory_hostname }}' 29 | 30 | - name: list kubernetes' pods 31 | command: kubectl {{ kubeconfig }} get pods --all-namespaces 32 | when: ' {{ play_hosts[0] == inventory_hostname }}' 33 | changed_when: false 34 | register: kubectl_get_pods 35 | tags: 36 | - output 37 | 38 | - name: print outpout of `kubectl get pods --all-namespaces` 39 | debug: msg="{{ kubectl_get_pods.stdout_lines }}" 40 | when: ' {{ play_hosts[0] == inventory_hostname }}' 41 | tags: 42 | - output 43 | -------------------------------------------------------------------------------- /tools/config_management/roles/setup-ansible/pre_tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set machine up to be able to run ansible playbooks. 3 | 4 | - name: check if python is installed (as required by ansible modules) 5 | raw: test -e /usr/bin/python 6 | register: is_python_installed 7 | failed_when: is_python_installed.rc not in [0, 1] 8 | changed_when: false # never mutates state. 9 | 10 | - name: install python if missing (as required by ansible modules) 11 | when: is_python_installed|failed # skip otherwise 12 | raw: (test -e /usr/bin/apt-get && apt-get install -y python-minimal) || (test -e /usr/bin/yum && yum install -y python) 13 | changed_when: is_python_installed.rc == 1 14 | 15 | - name: check if lsb_release is installed (as required for ansible facts) 16 | raw: test -e /usr/bin/lsb_release 17 | register: is_lsb_release_installed 18 | failed_when: is_lsb_release_installed.rc not in [0, 1] 19 | changed_when: false # never mutates state. 20 | 21 | - name: install lsb_release if missing (as required for ansible facts) 22 | when: is_lsb_release_installed|failed # skip otherwise 23 | raw: (test -e /usr/bin/apt-get && apt-get install -y lsb_release) || (test -e /usr/bin/yum && yum install -y lsb_release) 24 | changed_when: is_lsb_release_installed.rc == 1 25 | 26 | - setup: # gather 'facts', i.e. compensates for the above 'gather_facts: false'. 27 | -------------------------------------------------------------------------------- /tools/config_management/roles/setup-apt/files/apt-daily.timer.conf: -------------------------------------------------------------------------------- 1 | [Timer] 2 | Persistent=false 3 | -------------------------------------------------------------------------------- /tools/config_management/roles/setup-apt/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up apt 3 | 4 | # Ubuntu runs an apt update process that will run on first boot from image. 5 | # This is of questionable value when the machines are only going to live for a few minutes. 6 | # If you leave them on they will run the process daily. 7 | # Also we have seen the update process create a 'defunct' process which then throws off Weave Net smoke-test checks. 8 | # So, we override the 'persistent' setting so it will still run at the scheduled time but will not try to catch up on first boot. 9 | - name: copy apt daily override 10 | copy: src=apt-daily.timer.conf dest=/etc/systemd/system/apt-daily.timer.d/ 11 | -------------------------------------------------------------------------------- /tools/config_management/roles/sock-shop/tasks/tasks.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up sock-shop on top of Kubernetes. 3 | # Dependencies on other roles: 4 | # - kubernetes 5 | 6 | - name: create sock-shop namespace in k8s 7 | command: kubectl --kubeconfig /etc/kubernetes/admin.conf create namespace sock-shop 8 | 9 | - name: create sock-shop in k8s 10 | command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -n sock-shop -f "https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml?raw=true" 11 | 12 | - name: describe front-end service 13 | command: kubectl --kubeconfig /etc/kubernetes/admin.conf describe svc front-end -n sock-shop 14 | changed_when: false 15 | register: kubectl_describe_svc_frontend 16 | tags: 17 | - output 18 | 19 | - name: print outpout of `kubectl describe svc front-end -n sock-shop` 20 | debug: msg="{{ kubectl_describe_svc_frontend.stdout_lines }}" 21 | tags: 22 | - output 23 | 24 | - name: list sock-shop k8s' pods 25 | command: kubectl --kubeconfig /etc/kubernetes/admin.conf get pods -n sock-shop 26 | changed_when: false 27 | register: kubectl_get_pods 28 | tags: 29 | - output 30 | 31 | - name: print outpout of `kubectl get pods -n sock-shop` 32 | debug: msg="{{ kubectl_get_pods.stdout_lines }}" 33 | tags: 34 | - output 35 | -------------------------------------------------------------------------------- /tools/config_management/roles/weave-kube/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Weave Kube on top of Kubernetes. 3 | 4 | - name: set url for weave-kube daemonset 5 | set_fact: 6 | weave_kube_url: '{{ (kubernetes_version < "1.6") | ternary("https://git.io/weave-kube", "https://git.io/weave-kube-1.6") }}' 7 | 8 | - name: configure weave net's cni plugin 9 | command: 'kubectl {{ kubeconfig }} apply -f {{ weave_kube_url }}' 10 | when: '{{ play_hosts[0] == inventory_hostname }}' 11 | 12 | - name: list kubernetes' pods 13 | command: 'kubectl {{ kubeconfig }} get pods --all-namespaces' 14 | when: '{{ play_hosts[0] == inventory_hostname }}' 15 | changed_when: false 16 | register: kubectl_get_pods 17 | tags: 18 | - output 19 | 20 | - name: print outpout of `kubectl get pods --all-namespaces` 21 | debug: msg="{{ kubectl_get_pods.stdout_lines }}" 22 | when: '{{ play_hosts[0] == inventory_hostname }}' 23 | tags: 24 | - output 25 | -------------------------------------------------------------------------------- /tools/config_management/roles/weave-net-sources/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Development Environment for Weave Net. 3 | 4 | - name: check if weave net has been checked out 5 | become: false # Run as SSH-user 6 | stat: 7 | path: $HOME/src/github.com/weaveworks/weave 8 | register: weave 9 | failed_when: false 10 | changed_when: false 11 | 12 | - name: git clone weave net 13 | become: false # Run as SSH-user 14 | git: 15 | repo: https://github.com/weaveworks/weave.git 16 | dest: $HOME/src/github.com/weaveworks/weave 17 | when: not weave.stat.exists 18 | 19 | - name: create a convenience symlink to $HOME/src/github.com/weaveworks/weave 20 | become: false # Run as SSH-user 21 | file: 22 | src: $HOME/src/github.com/weaveworks/weave 23 | dest: $HOME/weave 24 | state: link 25 | -------------------------------------------------------------------------------- /tools/config_management/roles/weave-net-utilities/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: install epel-release 4 | package: 5 | name: "{{ item }}" 6 | state: present 7 | with_items: 8 | - epel-release 9 | when: ansible_os_family == "RedHat" 10 | 11 | - name: install jq 12 | package: 13 | name: "{{ item }}" 14 | state: present 15 | with_items: 16 | - jq 17 | 18 | - name: install ethtool (used by the weave script) 19 | package: 20 | name: "{{ item }}" 21 | state: present 22 | with_items: 23 | - ethtool 24 | 25 | - name: install nsenter (used by the weave script) 26 | command: docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter 27 | 28 | - name: install pip (for docker-py) 29 | package: 30 | name: "{{ item }}" 31 | state: present 32 | with_items: 33 | - python-pip 34 | 35 | - name: install docker-py (for docker_image) 36 | pip: 37 | name: docker-py 38 | state: present 39 | 40 | - name: docker pull images used by tests 41 | docker_image: 42 | name: '{{ item }}' 43 | state: present 44 | with_items: 45 | - alpine 46 | - aanand/docker-dnsutils 47 | - weaveworks/hello-world 48 | 49 | - name: docker pull docker-py which is used by tests 50 | docker_image: 51 | name: joffrey/docker-py 52 | tag: '{{ item }}' 53 | state: present 54 | with_items: 55 | - '1.8.1' 56 | - '1.9.0-rc2' 57 | -------------------------------------------------------------------------------- /tools/config_management/roles/weave-net/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Set up Weave Net. 3 | 4 | - name: install weave net 5 | get_url: 6 | url: https://git.io/weave 7 | dest: /usr/local/bin/weave 8 | mode: 0555 9 | 10 | - name: stop weave net 11 | command: /usr/local/bin/weave stop 12 | 13 | - name: start weave net 14 | command: /usr/local/bin/weave launch 15 | 16 | - name: get weave net's status 17 | command: /usr/local/bin/weave status 18 | changed_when: false 19 | register: weave_status 20 | tags: 21 | - output 22 | 23 | - name: print outpout of `weave status` 24 | debug: msg="{{ weave_status.stdout_lines }}" 25 | tags: 26 | - output 27 | -------------------------------------------------------------------------------- /tools/config_management/setup_bare_docker.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Docker from Docker's official repository 4 | ################################################################################ 5 | 6 | - name: install docker 7 | hosts: all 8 | gather_facts: false # required in case Python is not available on the host 9 | become: true 10 | become_user: root 11 | 12 | pre_tasks: 13 | - include: library/setup_ansible_dependencies.yml 14 | 15 | roles: 16 | - docker-install 17 | -------------------------------------------------------------------------------- /tools/config_management/setup_weave-kube.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Docker and Kubernetes, and configure Kubernetes to 4 | # use Weave Net's CNI plugin (a.k.a. Weave Kube). 5 | # 6 | # See also: 7 | # - http://kubernetes.io/docs/getting-started-guides/kubeadm/ 8 | # - https://github.com/weaveworks/weave-kube 9 | ################################################################################ 10 | 11 | - name: install docker, kubernetes and weave-kube 12 | hosts: all 13 | gather_facts: false # required in case Python is not available on the host 14 | become: true 15 | become_user: root 16 | 17 | pre_tasks: 18 | - include: library/setup_ansible_dependencies.yml 19 | 20 | roles: 21 | - docker-install 22 | - weave-net-utilities 23 | - kubernetes-install 24 | - kubernetes-docker-images 25 | - kubelet-stop 26 | - kubernetes-start 27 | - weave-kube 28 | -------------------------------------------------------------------------------- /tools/config_management/setup_weave-net_debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Docker from Docker's official repository and Weave Net. 4 | ################################################################################ 5 | 6 | - name: install docker and weave net for development 7 | hosts: all 8 | gather_facts: false # required in case Python is not available on the host 9 | become: true 10 | become_user: root 11 | 12 | pre_tasks: 13 | - include: library/setup_ansible_dependencies.yml 14 | 15 | roles: 16 | - docker-install 17 | - weave-net-utilities 18 | - weave-net 19 | -------------------------------------------------------------------------------- /tools/config_management/setup_weave-net_dev.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Docker from Docker's official repository and Weave Net. 4 | ################################################################################ 5 | 6 | - name: install docker and weave net for development 7 | hosts: all 8 | gather_facts: false # required in case Python is not available on the host 9 | become: true 10 | become_user: root 11 | 12 | pre_tasks: 13 | - include: library/setup_ansible_dependencies.yml 14 | 15 | roles: 16 | - setup-apt 17 | - dev-tools 18 | - golang-from-tarball 19 | - docker-install 20 | # Do not run this role when building with Vagrant, as sources have been already checked out: 21 | - { role: weave-net-sources, when: "ansible_user != 'vagrant'" } 22 | -------------------------------------------------------------------------------- /tools/config_management/setup_weave-net_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ################################################################################ 3 | # Install Docker from Docker's official repository and Weave Net. 4 | ################################################################################ 5 | 6 | - name: install docker and weave net for testing 7 | hosts: all 8 | gather_facts: false # required in case Python is not available on the host 9 | become: true 10 | become_user: root 11 | 12 | pre_tasks: 13 | - include: library/setup_ansible_dependencies.yml 14 | 15 | roles: 16 | - setup-apt 17 | - docker-install 18 | - weave-net-utilities 19 | - kubernetes-install 20 | - kubernetes-docker-images 21 | - kubelet-stop 22 | -------------------------------------------------------------------------------- /tools/cover/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | all: cover 4 | 5 | cover: *.go 6 | go get -tags netgo ./$(@D) 7 | go build -ldflags "-extldflags \"-static\" -linkmode=external" -tags netgo -o $@ ./$(@D) 8 | 9 | clean: 10 | rm -rf cover 11 | go clean ./... 12 | -------------------------------------------------------------------------------- /tools/cover/gather_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This scripts copies all the coverage reports from various circle shards, 3 | # merges them and produces a complete report. 4 | 5 | set -ex 6 | DESTINATION=$1 7 | FROMDIR=$2 8 | mkdir -p "$DESTINATION" 9 | 10 | if [ -n "$CIRCLECI" ]; then 11 | for i in $(seq 1 $((CIRCLE_NODE_TOTAL - 1))); do 12 | scp "node$i:$FROMDIR"/* "$DESTINATION" || true 13 | done 14 | fi 15 | 16 | go get github.com/weaveworks/build-tools/cover 17 | cover "$DESTINATION"/* >profile.cov 18 | go tool cover -html=profile.cov -o coverage.html 19 | go tool cover -func=profile.cov -o coverage.txt 20 | tar czf coverage.tar.gz "$DESTINATION" 21 | -------------------------------------------------------------------------------- /tools/files-with-type: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Find all files with a given MIME type. 4 | # 5 | # e.g. 6 | # $ files-with-type text/x-shellscript k8s infra 7 | 8 | mime_type=$1 9 | shift 10 | 11 | git ls-files "$@" | grep -vE '^vendor/' | xargs file --mime-type | grep "${mime_type}" | sed -e 's/:.*$//' 12 | -------------------------------------------------------------------------------- /tools/image-tag: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | WORKING_SUFFIX=$(if git status --porcelain | grep -qE '^(?:[^?][^ ]|[^ ][^?])\s'; then echo "-WIP"; else echo ""; fi) 8 | BRANCH_PREFIX=$(git rev-parse --abbrev-ref HEAD) 9 | 10 | # Fix the object name prefix length to 8 characters to have it consistent across the system. 11 | # See https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength 12 | echo "${BRANCH_PREFIX//\//-}-$(git rev-parse --short=8 HEAD)$WORKING_SUFFIX" 13 | -------------------------------------------------------------------------------- /tools/integration/run_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | # shellcheck disable=SC1090 7 | . "$DIR/config.sh" 8 | 9 | whitely echo Sanity checks 10 | if ! bash "$DIR/sanity_check.sh"; then 11 | whitely echo ...failed 12 | exit 1 13 | fi 14 | whitely echo ...ok 15 | 16 | # shellcheck disable=SC2068 17 | TESTS=(${@:-$(find . -name '*_test.sh')}) 18 | RUNNER_ARGS=() 19 | 20 | # If running on circle, use the scheduler to work out what tests to run 21 | if [ -n "$CIRCLECI" ] && [ -z "$NO_SCHEDULER" ]; then 22 | RUNNER_ARGS=("${RUNNER_ARGS[@]}" -scheduler) 23 | fi 24 | 25 | # If running on circle or PARALLEL is not empty, run tests in parallel 26 | if [ -n "$CIRCLECI" ] || [ -n "$PARALLEL" ]; then 27 | RUNNER_ARGS=("${RUNNER_ARGS[@]}" -parallel) 28 | fi 29 | 30 | make -C "${DIR}/../runner" 31 | HOSTS="$HOSTS" "${DIR}/../runner/runner" "${RUNNER_ARGS[@]}" "${TESTS[@]}" 32 | -------------------------------------------------------------------------------- /tools/integration/sanity_check.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # shellcheck disable=SC1090,SC1091 3 | . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config.sh" 4 | 5 | set -e 6 | 7 | whitely echo Ping each host from the other 8 | for host in $HOSTS; do 9 | for other in $HOSTS; do 10 | [ "$host" = "$other" ] || run_on "$host" "$PING" "$other" 11 | done 12 | done 13 | 14 | whitely echo Check we can reach docker 15 | 16 | for host in $HOSTS; do 17 | echo 18 | echo "Host Version Info: $host" 19 | echo "=====================================" 20 | echo "# docker version" 21 | docker_on "$host" version 22 | echo "# docker info" 23 | docker_on "$host" info 24 | echo "# weave version" 25 | weave_on "$host" version 26 | done 27 | -------------------------------------------------------------------------------- /tools/provisioning/aws/outputs.tf: -------------------------------------------------------------------------------- 1 | output "username" { 2 | value = "${lookup(var.aws_usernames, "${lookup(var.aws_amis, var.aws_dc)}")}" 3 | } 4 | 5 | output "public_ips" { 6 | value = ["${aws_instance.tf_test_vm.*.public_ip}"] 7 | } 8 | 9 | output "hostnames" { 10 | value = "${join("\n", 11 | "${formatlist("%v.%v.%v", 12 | aws_instance.tf_test_vm.*.tags.Name, 13 | aws_instance.tf_test_vm.*.availability_zone, 14 | var.app 15 | )}" 16 | )}" 17 | } 18 | 19 | # /etc/hosts file for the Droplets: 20 | output "private_etc_hosts" { 21 | value = "${join("\n", 22 | "${formatlist("%v %v.%v.%v", 23 | aws_instance.tf_test_vm.*.private_ip, 24 | aws_instance.tf_test_vm.*.tags.Name, 25 | aws_instance.tf_test_vm.*.availability_zone, 26 | var.app 27 | )}" 28 | )}" 29 | } 30 | 31 | # /etc/hosts file for the client: 32 | output "public_etc_hosts" { 33 | value = "${join("\n", 34 | "${formatlist("%v %v.%v.%v", 35 | aws_instance.tf_test_vm.*.public_ip, 36 | aws_instance.tf_test_vm.*.tags.Name, 37 | aws_instance.tf_test_vm.*.availability_zone, 38 | var.app 39 | )}" 40 | )}" 41 | } 42 | 43 | output "ansible_inventory" { 44 | value = "${format("[all]\n%s", join("\n", 45 | "${formatlist("%v private_ip=%v", 46 | aws_instance.tf_test_vm.*.public_ip, 47 | aws_instance.tf_test_vm.*.private_ip, 48 | )}" 49 | ))}" 50 | } 51 | 52 | output "private_key_path" { 53 | value = "${var.aws_private_key_path}" 54 | } 55 | -------------------------------------------------------------------------------- /tools/provisioning/aws/variables.tf: -------------------------------------------------------------------------------- 1 | variable "client_ip" { 2 | description = "IP address of the client machine" 3 | } 4 | 5 | variable "app" { 6 | description = "Name of the application using the created EC2 instance(s)." 7 | default = "default" 8 | } 9 | 10 | variable "name" { 11 | description = "Name of the EC2 instance(s)." 12 | default = "test" 13 | } 14 | 15 | variable "num_hosts" { 16 | description = "Number of EC2 instance(s)." 17 | default = 1 18 | } 19 | 20 | variable "aws_vpc_cidr_block" { 21 | description = "AWS VPC CIDR block to use to attribute private IP addresses." 22 | default = "172.31.0.0/16" 23 | } 24 | 25 | variable "aws_public_key_name" { 26 | description = "Name of the SSH keypair to use in AWS." 27 | } 28 | 29 | variable "aws_private_key_path" { 30 | description = "Path to file containing private key" 31 | default = "~/.ssh/id_rsa" 32 | } 33 | 34 | variable "aws_dc" { 35 | description = "The AWS region to create things in." 36 | default = "us-east-1" 37 | } 38 | 39 | variable "aws_amis" { 40 | default = { 41 | # Ubuntu Server 16.04 LTS (HVM), SSD Volume Type: 42 | "us-east-1" = "ami-40d28157" 43 | "eu-west-2" = "ami-23d0da47" 44 | 45 | # Red Hat Enterprise Linux 7.3 (HVM), SSD Volume Type: 46 | 47 | #"us-east-1" = "ami-b63769a1" 48 | 49 | # CentOS 7 (x86_64) - with Updates HVM 50 | 51 | #"us-east-1" = "ami-6d1c2007" 52 | } 53 | } 54 | 55 | variable "aws_usernames" { 56 | description = "User to SSH as into the AWS instance." 57 | 58 | default = { 59 | "ami-40d28157" = "ubuntu" # Ubuntu Server 16.04 LTS (HVM) 60 | "ami-b63769a1" = "ec2-user" # Red Hat Enterprise Linux 7.3 (HVM) 61 | "ami-6d1c2007" = "centos" # CentOS 7 (x86_64) - with Updates HVM 62 | } 63 | } 64 | 65 | variable "aws_size" { 66 | description = "AWS' selected machine size" 67 | default = "t2.medium" # Instance with 2 cores & 4 GB memory 68 | } 69 | -------------------------------------------------------------------------------- /tools/provisioning/do/main.tf: -------------------------------------------------------------------------------- 1 | provider "digitalocean" { 2 | # See README.md for setup instructions. 3 | } 4 | 5 | # Tags to label and organize droplets: 6 | resource "digitalocean_tag" "name" { 7 | name = "${var.name}" 8 | } 9 | 10 | resource "digitalocean_tag" "app" { 11 | name = "${var.app}" 12 | } 13 | 14 | resource "digitalocean_tag" "terraform" { 15 | name = "terraform" 16 | } 17 | 18 | resource "digitalocean_droplet" "tf_test_vm" { 19 | ssh_keys = ["${var.do_public_key_id}"] 20 | image = "${var.do_os}" 21 | region = "${var.do_dc}" 22 | size = "${var.do_size}" 23 | name = "${var.name}-${count.index}" 24 | count = "${var.num_hosts}" 25 | 26 | tags = [ 27 | "${var.app}", 28 | "${var.name}", 29 | "terraform", 30 | ] 31 | 32 | # Wait for machine to be SSH-able: 33 | provisioner "remote-exec" { 34 | inline = ["exit"] 35 | 36 | connection { 37 | type = "ssh" 38 | user = "${var.do_username}" 39 | private_key = "${file("${var.do_private_key_path}")}" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tools/provisioning/do/outputs.tf: -------------------------------------------------------------------------------- 1 | output "username" { 2 | value = "${var.do_username}" 3 | } 4 | 5 | output "public_ips" { 6 | value = ["${digitalocean_droplet.tf_test_vm.*.ipv4_address}"] 7 | } 8 | 9 | output "hostnames" { 10 | value = "${join("\n", 11 | "${formatlist("%v.%v.%v", 12 | digitalocean_droplet.tf_test_vm.*.name, 13 | digitalocean_droplet.tf_test_vm.*.region, 14 | var.app 15 | )}" 16 | )}" 17 | } 18 | 19 | # /etc/hosts file for the Droplets: 20 | # N.B.: by default Digital Ocean droplets only have public IPs, but in order to 21 | # be consistent with other providers' recipes, we provide an output to generate 22 | # an /etc/hosts file on the Droplets, even though it is using public IPs only. 23 | output "private_etc_hosts" { 24 | value = "${join("\n", 25 | "${formatlist("%v %v.%v.%v", 26 | digitalocean_droplet.tf_test_vm.*.ipv4_address, 27 | digitalocean_droplet.tf_test_vm.*.name, 28 | digitalocean_droplet.tf_test_vm.*.region, 29 | var.app 30 | )}" 31 | )}" 32 | } 33 | 34 | # /etc/hosts file for the client: 35 | output "public_etc_hosts" { 36 | value = "${join("\n", 37 | "${formatlist("%v %v.%v.%v", 38 | digitalocean_droplet.tf_test_vm.*.ipv4_address, 39 | digitalocean_droplet.tf_test_vm.*.name, 40 | digitalocean_droplet.tf_test_vm.*.region, 41 | var.app 42 | )}" 43 | )}" 44 | } 45 | 46 | output "ansible_inventory" { 47 | value = "${format("[all]\n%s", join("\n", 48 | "${formatlist("%v private_ip=%v", 49 | digitalocean_droplet.tf_test_vm.*.ipv4_address, 50 | digitalocean_droplet.tf_test_vm.*.ipv4_address 51 | )}" 52 | ))}" 53 | } 54 | 55 | output "private_key_path" { 56 | value = "${var.do_private_key_path}" 57 | } 58 | -------------------------------------------------------------------------------- /tools/provisioning/gcp/outputs.tf: -------------------------------------------------------------------------------- 1 | output "username" { 2 | value = "${var.gcp_username}" 3 | } 4 | 5 | output "public_ips" { 6 | value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip}"] 7 | } 8 | 9 | output "private_ips" { 10 | value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.address}"] 11 | } 12 | 13 | output "hostnames" { 14 | value = "${join("\n", 15 | "${formatlist("%v.%v.%v", 16 | google_compute_instance.tf_test_vm.*.name, 17 | google_compute_instance.tf_test_vm.*.zone, 18 | var.app 19 | )}" 20 | )}" 21 | } 22 | 23 | # /etc/hosts file for the Compute Engine instances: 24 | output "private_etc_hosts" { 25 | value = "${join("\n", 26 | "${formatlist("%v %v.%v.%v", 27 | google_compute_instance.tf_test_vm.*.network_interface.0.address, 28 | google_compute_instance.tf_test_vm.*.name, 29 | google_compute_instance.tf_test_vm.*.zone, 30 | var.app 31 | )}" 32 | )}" 33 | } 34 | 35 | # /etc/hosts file for the client: 36 | output "public_etc_hosts" { 37 | value = "${join("\n", 38 | "${formatlist("%v %v.%v.%v", 39 | google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip, 40 | google_compute_instance.tf_test_vm.*.name, 41 | google_compute_instance.tf_test_vm.*.zone, 42 | var.app 43 | )}" 44 | )}" 45 | } 46 | 47 | output "ansible_inventory" { 48 | value = "${format("[all]\n%s", join("\n", 49 | "${formatlist("%v private_ip=%v", 50 | google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip, 51 | google_compute_instance.tf_test_vm.*.network_interface.0.address 52 | )}" 53 | ))}" 54 | } 55 | 56 | output "private_key_path" { 57 | value = "${var.gcp_private_key_path}" 58 | } 59 | 60 | output "instances_names" { 61 | value = ["${google_compute_instance.tf_test_vm.*.name}"] 62 | } 63 | 64 | output "image" { 65 | value = "${var.gcp_image}" 66 | } 67 | 68 | output "zone" { 69 | value = "${var.gcp_zone}" 70 | } 71 | -------------------------------------------------------------------------------- /tools/provisioning/gcp/variables.tf: -------------------------------------------------------------------------------- 1 | variable "gcp_username" { 2 | description = "Google Cloud Platform SSH username" 3 | } 4 | 5 | variable "app" { 6 | description = "Name of the application using the created Compute Engine instance(s)." 7 | default = "default" 8 | } 9 | 10 | variable "name" { 11 | description = "Name of the Compute Engine instance(s)." 12 | default = "test" 13 | } 14 | 15 | variable "num_hosts" { 16 | description = "Number of Compute Engine instance(s)." 17 | default = 1 18 | } 19 | 20 | variable "client_ip" { 21 | description = "IP address of the client machine" 22 | } 23 | 24 | variable "gcp_public_key_path" { 25 | description = "Path to file containing public key" 26 | default = "~/.ssh/id_rsa.pub" 27 | } 28 | 29 | variable "gcp_private_key_path" { 30 | description = "Path to file containing private key" 31 | default = "~/.ssh/id_rsa" 32 | } 33 | 34 | variable "gcp_project" { 35 | description = "Google Cloud Platform project" 36 | default = "weave-net-tests" 37 | } 38 | 39 | variable "gcp_image" { 40 | # See also: https://cloud.google.com/compute/docs/images 41 | # For example: 42 | # - "ubuntu-os-cloud/ubuntu-1604-lts" 43 | # - "debian-cloud/debian-8" 44 | # - "centos-cloud/centos-7" 45 | # - "rhel-cloud/rhel7" 46 | description = "Google Cloud Platform OS" 47 | 48 | default = "ubuntu-os-cloud/ubuntu-1604-lts" 49 | } 50 | 51 | variable "gcp_size" { 52 | # See also: 53 | # $ gcloud compute machine-types list 54 | description = "Google Cloud Platform's selected machine size" 55 | 56 | default = "n1-standard-1" 57 | } 58 | 59 | variable "gcp_region" { 60 | description = "Google Cloud Platform's selected region" 61 | default = "us-central1" 62 | } 63 | 64 | variable "gcp_zone" { 65 | description = "Google Cloud Platform's selected zone" 66 | default = "us-central1-a" 67 | } 68 | 69 | variable "gcp_network" { 70 | description = "Google Cloud Platform's selected network" 71 | default = "test" 72 | } 73 | 74 | variable "gcp_network_global_cidr" { 75 | description = "CIDR covering all regions for the selected Google Cloud Platform network" 76 | default = "10.128.0.0/9" 77 | } 78 | -------------------------------------------------------------------------------- /tools/publish-site: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | : "${PRODUCT:=}" 7 | 8 | fatal() { 9 | echo "$@" >&2 10 | exit 1 11 | } 12 | 13 | if [ ! -d .git ]; then 14 | fatal "Current directory is not a git clone" 15 | fi 16 | 17 | if [ -z "${PRODUCT}" ]; then 18 | fatal "Must specify PRODUCT" 19 | fi 20 | 21 | if ! BRANCH=$(git symbolic-ref --short HEAD) || [ -z "$BRANCH" ]; then 22 | fatal "Could not determine branch" 23 | fi 24 | 25 | case "$BRANCH" in 26 | issues/*) 27 | VERSION="${BRANCH#issues/}" 28 | TAGS="$VERSION" 29 | ;; 30 | *) 31 | if echo "$BRANCH" | grep -qE '^[0-9]+\.[0-9]+'; then 32 | DESCRIBE=$(git describe --match 'v*') 33 | if ! VERSION=$(echo "$DESCRIBE" | grep -oP '(?<=^v)[0-9]+\.[0-9]+\.[0-9]+'); then 34 | fatal "Could not infer latest $BRANCH version from $DESCRIBE" 35 | fi 36 | TAGS="$VERSION latest" 37 | else 38 | VERSION="$BRANCH" 39 | TAGS="$VERSION" 40 | fi 41 | ;; 42 | esac 43 | 44 | for TAG in $TAGS; do 45 | echo ">>> Publishing $PRODUCT $VERSION to $1/docs/$PRODUCT/$TAG" 46 | wordepress \ 47 | --url "$1" --user "$2" --password "$3" \ 48 | --product "$PRODUCT" --version "$VERSION" --tag "$TAG" \ 49 | publish site 50 | done 51 | -------------------------------------------------------------------------------- /tools/push-images: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | QUAY_PREFIX=quay.io/ 8 | IMAGES=$(make images) 9 | IMAGE_TAG=$(./tools/image-tag) 10 | 11 | usage() { 12 | echo "$0 [-no-docker-hub]" 13 | } 14 | 15 | NO_DOCKER_HUB= 16 | while [ $# -gt 0 ]; do 17 | case "$1" in 18 | -no-docker-hub) 19 | NO_DOCKER_HUB=1 20 | shift 1 21 | ;; 22 | *) 23 | usage 24 | exit 2 25 | ;; 26 | esac 27 | done 28 | 29 | pids="" 30 | for image in ${IMAGES}; do 31 | if [[ "$image" == *"build"* ]]; then 32 | continue 33 | fi 34 | echo "Will push ${image}:${IMAGE_TAG}" 35 | docker push "${image}:${IMAGE_TAG}" & 36 | pids="$pids $!" 37 | 38 | if [ -z "$NO_DOCKER_HUB" ]; then 39 | # remove the quey prefix and push to docker hub 40 | docker_hub_image=${image#$QUAY_PREFIX} 41 | docker tag "${image}:${IMAGE_TAG}" "${docker_hub_image}:${IMAGE_TAG}" 42 | echo "Will push ${docker_hub_image}:${IMAGE_TAG}" 43 | docker push "${docker_hub_image}:${IMAGE_TAG}" & 44 | pids="$pids $!" 45 | fi 46 | done 47 | 48 | # Wait individually for tasks so we fail-exit on any non-zero return code 49 | for p in $pids; do 50 | wait "$p" 51 | done 52 | 53 | wait 54 | -------------------------------------------------------------------------------- /tools/runner/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | all: runner 4 | 5 | runner: *.go 6 | go get -tags netgo ./$(@D) 7 | go build -ldflags "-extldflags \"-static\" -linkmode=external" -tags netgo -o $@ ./$(@D) 8 | 9 | clean: 10 | rm -rf runner 11 | go clean ./... 12 | -------------------------------------------------------------------------------- /tools/sched: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys, string, urllib 3 | import requests 4 | from requests.packages.urllib3.util.retry import Retry 5 | from requests.adapters import HTTPAdapter 6 | import optparse 7 | 8 | session = requests.Session() 9 | adapter = HTTPAdapter( 10 | max_retries=Retry( 11 | connect=5, 12 | status=5, 13 | backoff_factor=0.1, 14 | status_forcelist=[500, 502, 503, 504] 15 | ) 16 | ) 17 | session.mount('http://', adapter) 18 | session.mount('https://', adapter) 19 | 20 | 21 | def test_time(target, test_name, runtime): 22 | r = session.post(target + "/record/%s/%f" % (urllib.quote(test_name, safe=""), runtime)) 23 | print r.text.encode('utf-8') 24 | assert r.status_code == 204 25 | 26 | def test_sched(target, test_run, shard_count, shard_id): 27 | tests = {'tests': string.split(sys.stdin.read())} 28 | r = session.post(target + "/schedule/%s/%d/%d" % (test_run, shard_count, shard_id), json=tests) 29 | assert r.status_code == 200 30 | result = r.json() 31 | for test in sorted(result['tests']): 32 | print test.encode('utf-8') 33 | 34 | def usage(): 35 | print "%s (--target=...) " % sys.argv[0] 36 | print " time " 37 | print " sched " 38 | 39 | def main(): 40 | parser = optparse.OptionParser() 41 | parser.add_option('--target', default="http://positive-cocoa-90213.appspot.com") 42 | options, args = parser.parse_args() 43 | if len(args) < 3: 44 | usage() 45 | sys.exit(1) 46 | 47 | if args[0] == "time": 48 | test_time(options.target, args[1], float(args[2])) 49 | elif args[0] == "sched": 50 | test_sched(options.target, args[1], int(args[2]), int(args[3])) 51 | else: 52 | usage() 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /tools/scheduler/.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | -------------------------------------------------------------------------------- /tools/scheduler/app.yaml: -------------------------------------------------------------------------------- 1 | application: positive-cocoa-90213 2 | version: 1 3 | runtime: python27 4 | api_version: 1 5 | threadsafe: true 6 | 7 | handlers: 8 | - url: .* 9 | script: main.app 10 | 11 | libraries: 12 | - name: webapp2 13 | version: latest 14 | - name: ssl 15 | version: latest 16 | -------------------------------------------------------------------------------- /tools/scheduler/appengine_config.py: -------------------------------------------------------------------------------- 1 | from google.appengine.ext import vendor 2 | 3 | vendor.add('lib') 4 | -------------------------------------------------------------------------------- /tools/scheduler/cron.yaml: -------------------------------------------------------------------------------- 1 | cron: 2 | - description: periodic gc 3 | url: /tasks/gc 4 | schedule: every 5 minutes 5 | -------------------------------------------------------------------------------- /tools/scheduler/requirements.txt: -------------------------------------------------------------------------------- 1 | flask==0.12.4 2 | google-api-python-client==1.6.7 3 | -------------------------------------------------------------------------------- /tools/shell-lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Lint all shell files in given directories with `shellcheck`. 4 | # 5 | # e.g. 6 | # $ shell-lint infra k8s 7 | # 8 | # Depends on: 9 | # - shellcheck 10 | # - files-with-type 11 | # - file >= 5.22 12 | 13 | "$(dirname "${BASH_SOURCE[0]}")/files-with-type" text/x-shellscript "$@" | xargs --no-run-if-empty shellcheck 14 | -------------------------------------------------------------------------------- /tools/socks/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gliderlabs/alpine 2 | WORKDIR / 3 | COPY proxy / 4 | EXPOSE 8000 5 | EXPOSE 8080 6 | ENTRYPOINT ["/proxy"] 7 | 8 | ARG revision 9 | LABEL maintainer="Weaveworks " \ 10 | org.opencontainers.image.title="socks" \ 11 | org.opencontainers.image.source="https://github.com/weaveworks/build-tools/tree/master/socks" \ 12 | org.opencontainers.image.revision="${revision}" \ 13 | org.opencontainers.image.vendor="Weaveworks" 14 | -------------------------------------------------------------------------------- /tools/socks/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | IMAGE_TAR=image.tar 4 | IMAGE_NAME=weaveworks/socksproxy 5 | GIT_REVISION := $(shell git rev-parse HEAD) 6 | PROXY_EXE=proxy 7 | NETGO_CHECK=@strings $@ | grep cgo_stub\\\.go >/dev/null || { \ 8 | rm $@; \ 9 | echo "\nYour go standard library was built without the 'netgo' build tag."; \ 10 | echo "To fix that, run"; \ 11 | echo " sudo go clean -i net"; \ 12 | echo " sudo go install -tags netgo std"; \ 13 | false; \ 14 | } 15 | 16 | all: $(IMAGE_TAR) 17 | 18 | $(IMAGE_TAR): Dockerfile $(PROXY_EXE) 19 | docker build --build-arg=revision=$(GIT_REVISION) -t $(IMAGE_NAME) . 20 | docker save $(IMAGE_NAME):latest > $@ 21 | 22 | $(PROXY_EXE): *.go 23 | go get -tags netgo ./$(@D) 24 | go build -ldflags "-extldflags \"-static\" -linkmode=external" -tags netgo -o $@ ./$(@D) 25 | $(NETGO_CHECK) 26 | 27 | clean: 28 | -docker rmi $(IMAGE_NAME) 29 | rm -rf $(PROXY_EXE) $(IMAGE_TAR) 30 | go clean ./... 31 | -------------------------------------------------------------------------------- /tools/socks/README.md: -------------------------------------------------------------------------------- 1 | # SOCKS Proxy 2 | 3 | The challenge: you’ve built and deployed your microservices based 4 | application on a Weave network, running on a set of VMs on EC2. Many 5 | of the services’ public API are reachable from the internet via an 6 | Nginx-based reverse proxy, but some of the services also expose 7 | private monitoring and manage endpoints via embedded HTTP servers. 8 | How do I securely get access to these from my laptop, without exposing 9 | them to the world? 10 | 11 | One method we’ve started using at Weaveworks is a 90’s technology - a 12 | SOCKS proxy combined with a PAC script. It’s relatively 13 | straight-forward: one ssh’s into any of the VMs participating in the 14 | Weave network, starts the SOCKS proxy in a container on Weave the 15 | network, and SSH port forwards a few local port to the proxy. All 16 | that’s left is for the user to configure his browser to use the proxy, 17 | and voila, you can now access your Docker containers, via the Weave 18 | network (and with all the magic of weavedns), from your laptop’s 19 | browser! 20 | 21 | It is perhaps worth noting there is nothing Weave-specific about this 22 | approach - this should work with any SDN or private network. 23 | 24 | A quick example: 25 | 26 | ``` 27 | vm1$ weave launch 28 | vm1$ eval $(weave env) 29 | vm1$ docker run -d --name nginx nginx 30 | ``` 31 | 32 | And on your laptop 33 | 34 | ``` 35 | laptop$ git clone https://github.com/weaveworks/tools 36 | laptop$ cd tools/socks 37 | laptop$ ./connect.sh vm1 38 | Starting proxy container... 39 | Please configure your browser for proxy 40 | http://localhost:8080/proxy.pac 41 | ``` 42 | 43 | To configure your Mac to use the proxy: 44 | 45 | 1. Open System Preferences 46 | 2. Select Network 47 | 3. Click the 'Advanced' button 48 | 4. Select the Proxies tab 49 | 5. Click the 'Automatic Proxy Configuration' check box 50 | 6. Enter 'http://localhost:8080/proxy.pac' in the URL box 51 | 7. Remove `*.local` from the 'Bypass proxy settings for these Hosts & Domains' 52 | 53 | Now point your browser at http://nginx.weave.local/ 54 | -------------------------------------------------------------------------------- /tools/socks/connect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | if [ $# -ne 1 ]; then 6 | echo "Usage: $0 " 7 | exit 1 8 | fi 9 | 10 | HOST=$1 11 | 12 | echo "Starting proxy container..." 13 | PROXY_CONTAINER=$(ssh "$HOST" weave run -d weaveworks/socksproxy) 14 | 15 | function finish() { 16 | echo "Removing proxy container.." 17 | # shellcheck disable=SC2029 18 | ssh "$HOST" docker rm -f "$PROXY_CONTAINER" 19 | } 20 | trap finish EXIT 21 | 22 | # shellcheck disable=SC2029 23 | PROXY_IP=$(ssh "$HOST" -- "docker inspect --format='{{.NetworkSettings.IPAddress}}' $PROXY_CONTAINER") 24 | echo 'Please configure your browser for proxy http://localhost:8080/proxy.pac' 25 | # shellcheck disable=SC2029 26 | ssh "-L8000:$PROXY_IP:8000" "-L8080:$PROXY_IP:8080" "$HOST" docker attach "$PROXY_CONTAINER" 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | ) 6 | 7 | var log = logrus.New() 8 | 9 | func init() { 10 | log.Formatter = new(logrus.JSONFormatter) 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Level = logrus.DebugLevel 13 | } 14 | 15 | func main() { 16 | defer func() { 17 | err := recover() 18 | if err != nil { 19 | log.WithFields(logrus.Fields{ 20 | "omg": true, 21 | "err": err, 22 | "number": 100, 23 | }).Fatal("The ice breaks!") 24 | } 25 | }() 26 | 27 | log.WithFields(logrus.Fields{ 28 | "animal": "walrus", 29 | "number": 8, 30 | }).Debug("Started observing beach") 31 | 32 | log.WithFields(logrus.Fields{ 33 | "animal": "walrus", 34 | "size": 10, 35 | }).Info("A group of walrus emerges from the ocean") 36 | 37 | log.WithFields(logrus.Fields{ 38 | "omg": true, 39 | "number": 122, 40 | }).Warn("The group's number increased tremendously!") 41 | 42 | log.WithFields(logrus.Fields{ 43 | "temperature": -4, 44 | }).Debug("Temperature changes") 45 | 46 | log.WithFields(logrus.Fields{ 47 | "animal": "orca", 48 | "size": 9009, 49 | }).Panic("It's over 9000!") 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/hook/hook.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "gopkg.in/gemnasium/logrus-airbrake-hook.v2" 6 | ) 7 | 8 | var log = logrus.New() 9 | 10 | func init() { 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Hooks.Add(airbrake.NewHook(123, "xyz", "development")) 13 | } 14 | 15 | func main() { 16 | log.WithFields(logrus.Fields{ 17 | "animal": "walrus", 18 | "size": 10, 19 | }).Info("A group of walrus emerges from the ocean") 20 | 21 | log.WithFields(logrus.Fields{ 22 | "omg": true, 23 | "number": 122, 24 | }).Warn("The group's number increased tremendously!") 25 | 26 | log.WithFields(logrus.Fields{ 27 | "omg": true, 28 | "number": 100, 29 | }).Fatal("The ice breaks!") 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | if t, ok := data["time"]; ok { 35 | data["fields.time"] = t 36 | } 37 | 38 | if m, ok := data["msg"]; ok { 39 | data["fields.msg"] = m 40 | } 41 | 42 | if l, ok := data["level"]; ok { 43 | data["fields.level"] = l 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!nacl,!plan9 2 | 3 | package logrus_syslog 4 | 5 | import ( 6 | "fmt" 7 | "github.com/Sirupsen/logrus" 8 | "log/syslog" 9 | "os" 10 | ) 11 | 12 | // SyslogHook to send logs via syslog. 13 | type SyslogHook struct { 14 | Writer *syslog.Writer 15 | SyslogNetwork string 16 | SyslogRaddr string 17 | } 18 | 19 | // Creates a hook to be added to an instance of logger. This is called with 20 | // `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")` 21 | // `if err == nil { log.Hooks.Add(hook) }` 22 | func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) { 23 | w, err := syslog.Dial(network, raddr, priority, tag) 24 | return &SyslogHook{w, network, raddr}, err 25 | } 26 | 27 | func (hook *SyslogHook) Fire(entry *logrus.Entry) error { 28 | line, err := entry.String() 29 | if err != nil { 30 | fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err) 31 | return err 32 | } 33 | 34 | switch entry.Level { 35 | case logrus.PanicLevel: 36 | return hook.Writer.Crit(line) 37 | case logrus.FatalLevel: 38 | return hook.Writer.Crit(line) 39 | case logrus.ErrorLevel: 40 | return hook.Writer.Err(line) 41 | case logrus.WarnLevel: 42 | return hook.Writer.Warning(line) 43 | case logrus.InfoLevel: 44 | return hook.Writer.Info(line) 45 | case logrus.DebugLevel: 46 | return hook.Writer.Debug(line) 47 | default: 48 | return nil 49 | } 50 | } 51 | 52 | func (hook *SyslogHook) Levels() []logrus.Level { 53 | return logrus.AllLevels 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/test/test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | // test.Hook is a hook designed for dealing with logs in test scenarios. 10 | type Hook struct { 11 | Entries []*logrus.Entry 12 | } 13 | 14 | // Installs a test hook for the global logger. 15 | func NewGlobal() *Hook { 16 | 17 | hook := new(Hook) 18 | logrus.AddHook(hook) 19 | 20 | return hook 21 | 22 | } 23 | 24 | // Installs a test hook for a given local logger. 25 | func NewLocal(logger *logrus.Logger) *Hook { 26 | 27 | hook := new(Hook) 28 | logger.Hooks.Add(hook) 29 | 30 | return hook 31 | 32 | } 33 | 34 | // Creates a discarding logger and installs the test hook. 35 | func NewNullLogger() (*logrus.Logger, *Hook) { 36 | 37 | logger := logrus.New() 38 | logger.Out = ioutil.Discard 39 | 40 | return logger, NewLocal(logger) 41 | 42 | } 43 | 44 | func (t *Hook) Fire(e *logrus.Entry) error { 45 | t.Entries = append(t.Entries, e) 46 | return nil 47 | } 48 | 49 | func (t *Hook) Levels() []logrus.Level { 50 | return logrus.AllLevels 51 | } 52 | 53 | // LastEntry returns the last entry that was logged or nil. 54 | func (t *Hook) LastEntry() (l *logrus.Entry) { 55 | 56 | if i := len(t.Entries) - 1; i < 0 { 57 | return nil 58 | } else { 59 | return t.Entries[i] 60 | } 61 | 62 | } 63 | 64 | // Reset removes all Entries from this test hook. 65 | func (t *Hook) Reset() { 66 | t.Entries = make([]*logrus.Entry, 0) 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type fieldKey string 9 | type FieldMap map[fieldKey]string 10 | 11 | const ( 12 | FieldKeyMsg = "msg" 13 | FieldKeyLevel = "level" 14 | FieldKeyTime = "time" 15 | ) 16 | 17 | func (f FieldMap) resolve(key fieldKey) string { 18 | if k, ok := f[key]; ok { 19 | return k 20 | } 21 | 22 | return string(key) 23 | } 24 | 25 | type JSONFormatter struct { 26 | // TimestampFormat sets the format used for marshaling timestamps. 27 | TimestampFormat string 28 | 29 | // DisableTimestamp allows disabling automatic timestamps in output 30 | DisableTimestamp bool 31 | 32 | // FieldMap allows users to customize the names of keys for various fields. 33 | // As an example: 34 | // formatter := &JSONFormatter{ 35 | // FieldMap: FieldMap{ 36 | // FieldKeyTime: "@timestamp", 37 | // FieldKeyLevel: "@level", 38 | // FieldKeyLevel: "@message", 39 | // }, 40 | // } 41 | FieldMap FieldMap 42 | } 43 | 44 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 45 | data := make(Fields, len(entry.Data)+3) 46 | for k, v := range entry.Data { 47 | switch v := v.(type) { 48 | case error: 49 | // Otherwise errors are ignored by `encoding/json` 50 | // https://github.com/Sirupsen/logrus/issues/137 51 | data[k] = v.Error() 52 | default: 53 | data[k] = v 54 | } 55 | } 56 | prefixFieldClashes(data) 57 | 58 | timestampFormat := f.TimestampFormat 59 | if timestampFormat == "" { 60 | timestampFormat = DefaultTimestampFormat 61 | } 62 | 63 | if !f.DisableTimestamp { 64 | data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) 65 | } 66 | data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message 67 | data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() 68 | 69 | serialized, err := json.Marshal(data) 70 | if err != nil { 71 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 72 | } 73 | return append(serialized, '\n'), nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | // IsTerminal returns true if stderr's file descriptor is a terminal. 6 | func IsTerminal() bool { 7 | return true 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package logrus 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | package logrus 9 | 10 | import "syscall" 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | type Termios syscall.Termios 15 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | // +build !appengine 8 | 9 | package logrus 10 | 11 | import ( 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | // IsTerminal returns true if stderr's file descriptor is a terminal. 17 | func IsTerminal() bool { 18 | fd := syscall.Stderr 19 | var termios Termios 20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 21 | return err == 0 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows,!appengine 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | return logger.WriterLevel(InfoLevel) 11 | } 12 | 13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { 14 | reader, writer := io.Pipe() 15 | 16 | var printFunc func(args ...interface{}) 17 | switch level { 18 | case DebugLevel: 19 | printFunc = logger.Debug 20 | case InfoLevel: 21 | printFunc = logger.Info 22 | case WarnLevel: 23 | printFunc = logger.Warn 24 | case ErrorLevel: 25 | printFunc = logger.Error 26 | case FatalLevel: 27 | printFunc = logger.Fatal 28 | case PanicLevel: 29 | printFunc = logger.Panic 30 | default: 31 | printFunc = logger.Print 32 | } 33 | 34 | go logger.writerScanner(reader, printFunc) 35 | runtime.SetFinalizer(writer, writerFinalizer) 36 | 37 | return writer 38 | } 39 | 40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 41 | scanner := bufio.NewScanner(reader) 42 | for scanner.Scan() { 43 | printFunc(scanner.Text()) 44 | } 45 | if err := scanner.Err(); err != nil { 46 | logger.Errorf("Error while reading from Writer: %s", err) 47 | } 48 | reader.Close() 49 | } 50 | 51 | func writerFinalizer(writer *io.PipeWriter) { 52 | writer.Close() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/beorn7/perks/quantile/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Blake Mizerany 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/julienschmidt/httprouter/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Julien Schmidt. All rights reserved. 2 | 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * The names of the contributors may not be used to endorse or promote 12 | products derived from this software without specific prior written 13 | permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL JULIEN SCHMIDT BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 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 pbutil provides record length-delimited Protocol Buffer streaming. 16 | package pbutil 17 | -------------------------------------------------------------------------------- /vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Matt T. Proud 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 pbutil 16 | 17 | import ( 18 | "encoding/binary" 19 | "io" 20 | 21 | "github.com/golang/protobuf/proto" 22 | ) 23 | 24 | // WriteDelimited encodes and dumps a message to the provided writer prefixed 25 | // with a 32-bit varint indicating the length of the encoded message, producing 26 | // a length-delimited record stream, which can be used to chain together 27 | // encoded messages of the same type together in a file. It returns the total 28 | // number of bytes written and any applicable error. This is roughly 29 | // equivalent to the companion Java API's MessageLite#writeDelimitedTo. 30 | func WriteDelimited(w io.Writer, m proto.Message) (n int, err error) { 31 | buffer, err := proto.Marshal(m) 32 | if err != nil { 33 | return 0, err 34 | } 35 | 36 | var buf [binary.MaxVarintLen32]byte 37 | encodedLength := binary.PutUvarint(buf[:], uint64(len(buffer))) 38 | 39 | sync, err := w.Write(buf[:encodedLength]) 40 | if err != nil { 41 | return sync, err 42 | } 43 | 44 | n, err = w.Write(buffer) 45 | return n + sync, err 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/client_golang/prometheus/fnv.go: -------------------------------------------------------------------------------- 1 | package prometheus 2 | 3 | // Inline and byte-free variant of hash/fnv's fnv64a. 4 | 5 | const ( 6 | offset64 = 14695981039346656037 7 | prime64 = 1099511628211 8 | ) 9 | 10 | // hashNew initializies a new fnv64a hash value. 11 | func hashNew() uint64 { 12 | return offset64 13 | } 14 | 15 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 16 | func hashAdd(h uint64, s string) uint64 { 17 | for i := 0; i < len(s); i++ { 18 | h ^= uint64(s[i]) 19 | h *= prime64 20 | } 21 | return h 22 | } 23 | 24 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 25 | func hashAddByte(h uint64, b byte) uint64 { 26 | h ^= uint64(b) 27 | h *= prime64 28 | return h 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/config/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package config 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | ) 20 | 21 | func checkOverflow(m map[string]interface{}, ctx string) error { 22 | if len(m) > 0 { 23 | var keys []string 24 | for k := range m { 25 | keys = append(keys, k) 26 | } 27 | return fmt.Errorf("unknown fields in %s: %s", ctx, strings.Join(keys, ", ")) 28 | } 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/expfmt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // A package for reading and writing Prometheus metrics. 15 | package expfmt 16 | 17 | type Format string 18 | 19 | const ( 20 | TextVersion = "0.0.4" 21 | 22 | ProtoType = `application/vnd.google.protobuf` 23 | ProtoProtocol = `io.prometheus.client.MetricFamily` 24 | ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" 25 | 26 | // The Content-Type values for the different wire protocols. 27 | FmtUnknown Format = `` 28 | FmtText Format = `text/plain; version=` + TextVersion 29 | FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` 30 | FmtProtoText Format = ProtoFmt + ` encoding=text` 31 | FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` 32 | ) 33 | 34 | const ( 35 | hdrContentType = "Content-Type" 36 | hdrAccept = "Accept" 37 | ) 38 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/expfmt/fuzz.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Build only when actually fuzzing 15 | // +build gofuzz 16 | 17 | package expfmt 18 | 19 | import "bytes" 20 | 21 | // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: 22 | // 23 | // go-fuzz-build github.com/prometheus/common/expfmt 24 | // go-fuzz -bin expfmt-fuzz.zip -workdir fuzz 25 | // 26 | // Further input samples should go in the folder fuzz/corpus. 27 | func Fuzz(in []byte) int { 28 | parser := TextParser{} 29 | _, err := parser.TextToMetricFamilies(bytes.NewReader(in)) 30 | 31 | if err != nil { 32 | return 0 33 | } 34 | 35 | return 1 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/fnv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package model 15 | 16 | // Inline and byte-free variant of hash/fnv's fnv64a. 17 | 18 | const ( 19 | offset64 = 14695981039346656037 20 | prime64 = 1099511628211 21 | ) 22 | 23 | // hashNew initializies a new fnv64a hash value. 24 | func hashNew() uint64 { 25 | return offset64 26 | } 27 | 28 | // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 29 | func hashAdd(h uint64, s string) uint64 { 30 | for i := 0; i < len(s); i++ { 31 | h ^= uint64(s[i]) 32 | h *= prime64 33 | } 34 | return h 35 | } 36 | 37 | // hashAddByte adds a byte to a fnv64a hash value, returning the updated hash. 38 | func hashAddByte(h uint64, b byte) uint64 { 39 | h ^= uint64(b) 40 | h *= prime64 41 | return h 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/common/model/model.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package model contains common data structures that are shared across 15 | // Prometheus components and libraries. 16 | package model 17 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Prometheus Team 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package procfs provides functions to retrieve system, kernel and process 15 | // metrics from the pseudo-filesystem proc. 16 | // 17 | // Example: 18 | // 19 | // package main 20 | // 21 | // import ( 22 | // "fmt" 23 | // "log" 24 | // 25 | // "github.com/prometheus/procfs" 26 | // ) 27 | // 28 | // func main() { 29 | // p, err := procfs.Self() 30 | // if err != nil { 31 | // log.Fatalf("could not get process: %s", err) 32 | // } 33 | // 34 | // stat, err := p.NewStat() 35 | // if err != nil { 36 | // log.Fatalf("could not get process stat: %s", err) 37 | // } 38 | // 39 | // fmt.Printf("command: %s\n", stat.Comm) 40 | // fmt.Printf("cpu time: %fs\n", stat.CPUTime()) 41 | // fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) 42 | // fmt.Printf("rss: %dB\n", stat.ResidentMemory()) 43 | // } 44 | // 45 | package procfs 46 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/fs.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | ) 8 | 9 | // FS represents the pseudo-filesystem proc, which provides an interface to 10 | // kernel data structures. 11 | type FS string 12 | 13 | // DefaultMountPoint is the common mount point of the proc filesystem. 14 | const DefaultMountPoint = "/proc" 15 | 16 | // NewFS returns a new FS mounted under the given mountPoint. It will error 17 | // if the mount point can't be read. 18 | func NewFS(mountPoint string) (FS, error) { 19 | info, err := os.Stat(mountPoint) 20 | if err != nil { 21 | return "", fmt.Errorf("could not read %s: %s", mountPoint, err) 22 | } 23 | if !info.IsDir() { 24 | return "", fmt.Errorf("mount point %s is not a directory", mountPoint) 25 | } 26 | 27 | return FS(mountPoint), nil 28 | } 29 | 30 | // Path returns the path of the given subsystem relative to the procfs root. 31 | func (fs FS) Path(p ...string) string { 32 | return path.Join(append([]string{string(fs)}, p...)...) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/proc_io.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | ) 8 | 9 | // ProcIO models the content of /proc//io. 10 | type ProcIO struct { 11 | // Chars read. 12 | RChar uint64 13 | // Chars written. 14 | WChar uint64 15 | // Read syscalls. 16 | SyscR uint64 17 | // Write syscalls. 18 | SyscW uint64 19 | // Bytes read. 20 | ReadBytes uint64 21 | // Bytes written. 22 | WriteBytes uint64 23 | // Bytes written, but taking into account truncation. See 24 | // Documentation/filesystems/proc.txt in the kernel sources for 25 | // detailed explanation. 26 | CancelledWriteBytes int64 27 | } 28 | 29 | // NewIO creates a new ProcIO instance from a given Proc instance. 30 | func (p Proc) NewIO() (ProcIO, error) { 31 | pio := ProcIO{} 32 | 33 | f, err := os.Open(p.path("io")) 34 | if err != nil { 35 | return pio, err 36 | } 37 | defer f.Close() 38 | 39 | data, err := ioutil.ReadAll(f) 40 | if err != nil { 41 | return pio, err 42 | } 43 | 44 | ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" + 45 | "read_bytes: %d\nwrite_bytes: %d\n" + 46 | "cancelled_write_bytes: %d\n" 47 | 48 | _, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR, 49 | &pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes) 50 | if err != nil { 51 | return pio, err 52 | } 53 | 54 | return pio, nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/prometheus/procfs/stat.go: -------------------------------------------------------------------------------- 1 | package procfs 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | // Stat represents kernel/system statistics. 12 | type Stat struct { 13 | // Boot time in seconds since the Epoch. 14 | BootTime int64 15 | } 16 | 17 | // NewStat returns kernel/system statistics read from /proc/stat. 18 | func NewStat() (Stat, error) { 19 | fs, err := NewFS(DefaultMountPoint) 20 | if err != nil { 21 | return Stat{}, err 22 | } 23 | 24 | return fs.NewStat() 25 | } 26 | 27 | // NewStat returns an information about current kernel/system statistics. 28 | func (fs FS) NewStat() (Stat, error) { 29 | f, err := os.Open(fs.Path("stat")) 30 | if err != nil { 31 | return Stat{}, err 32 | } 33 | defer f.Close() 34 | 35 | s := bufio.NewScanner(f) 36 | for s.Scan() { 37 | line := s.Text() 38 | if !strings.HasPrefix(line, "btime") { 39 | continue 40 | } 41 | fields := strings.Fields(line) 42 | if len(fields) != 2 { 43 | return Stat{}, fmt.Errorf("couldn't parse %s line %s", f.Name(), line) 44 | } 45 | i, err := strconv.ParseInt(fields[1], 10, 32) 46 | if err != nil { 47 | return Stat{}, fmt.Errorf("couldn't parse %s: %s", fields[1], err) 48 | } 49 | return Stat{BootTime: i}, nil 50 | } 51 | if err := s.Err(); err != nil { 52 | return Stat{}, fmt.Errorf("couldn't parse %s: %s", f.Name(), err) 53 | } 54 | 55 | return Stat{}, fmt.Errorf("couldn't parse %s, missing btime", f.Name()) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/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/unix/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/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_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_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, 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-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /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_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /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/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /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 linux,mips linux,mipsle 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/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.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 darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.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 darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /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/golang.org/x/sys/windows/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/windows/asm_windows_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 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 windows 6 | // +build go1.4 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | func Unsetenv(key string) error { 13 | // This was added in Go 1.4. 14 | return syscall.Unsetenv(key) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.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 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.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 windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.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 windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.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 windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.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 windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/mksyscall.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 registry 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/syscall.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 windows 6 | 7 | package registry 8 | 9 | import "syscall" 10 | 11 | const ( 12 | _REG_OPTION_NON_VOLATILE = 0 13 | 14 | _REG_CREATED_NEW_KEY = 1 15 | _REG_OPENED_EXISTING_KEY = 2 16 | 17 | _ERROR_NO_MORE_ITEMS syscall.Errno = 259 18 | ) 19 | 20 | func LoadRegLoadMUIString() error { 21 | return procRegLoadMUIStringW.Find() 22 | } 23 | 24 | //sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW 25 | //sys regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW 26 | //sys regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW 27 | //sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegEnumValueW 28 | //sys regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) = advapi32.RegDeleteValueW 29 | //sys regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) = advapi32.RegLoadMUIStringW 30 | //sys regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) = advapi32.RegConnectRegistryW 31 | 32 | //sys expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/log.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 windows 6 | 7 | package debug 8 | 9 | import ( 10 | "os" 11 | "strconv" 12 | ) 13 | 14 | // Log interface allows different log implementations to be used. 15 | type Log interface { 16 | Close() error 17 | Info(eid uint32, msg string) error 18 | Warning(eid uint32, msg string) error 19 | Error(eid uint32, msg string) error 20 | } 21 | 22 | // ConsoleLog provides access to the console. 23 | type ConsoleLog struct { 24 | Name string 25 | } 26 | 27 | // New creates new ConsoleLog. 28 | func New(source string) *ConsoleLog { 29 | return &ConsoleLog{Name: source} 30 | } 31 | 32 | // Close closes console log l. 33 | func (l *ConsoleLog) Close() error { 34 | return nil 35 | } 36 | 37 | func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { 38 | s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" 39 | _, err := os.Stdout.Write([]byte(s)) 40 | return err 41 | } 42 | 43 | // Info writes an information event msg with event id eid to the console l. 44 | func (l *ConsoleLog) Info(eid uint32, msg string) error { 45 | return l.report("info", eid, msg) 46 | } 47 | 48 | // Warning writes an warning event msg with event id eid to the console l. 49 | func (l *ConsoleLog) Warning(eid uint32, msg string) error { 50 | return l.report("warn", eid, msg) 51 | } 52 | 53 | // Error writes an error event msg with event id eid to the console l. 54 | func (l *ConsoleLog) Error(eid uint32, msg string) error { 55 | return l.report("error", eid, msg) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/service.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 windows 6 | 7 | // Package debug provides facilities to execute svc.Handler on console. 8 | // 9 | package debug 10 | 11 | import ( 12 | "os" 13 | "os/signal" 14 | "syscall" 15 | 16 | "golang.org/x/sys/windows/svc" 17 | ) 18 | 19 | // Run executes service name by calling appropriate handler function. 20 | // The process is running on console, unlike real service. Use Ctrl+C to 21 | // send "Stop" command to your service. 22 | func Run(name string, handler svc.Handler) error { 23 | cmds := make(chan svc.ChangeRequest) 24 | changes := make(chan svc.Status) 25 | 26 | sig := make(chan os.Signal) 27 | signal.Notify(sig) 28 | 29 | go func() { 30 | status := svc.Status{State: svc.Stopped} 31 | for { 32 | select { 33 | case <-sig: 34 | cmds <- svc.ChangeRequest{svc.Stop, status} 35 | case status = <-changes: 36 | } 37 | } 38 | }() 39 | 40 | _, errno := handler.Execute([]string{name}, cmds, changes) 41 | if errno != 0 { 42 | return syscall.Errno(errno) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/event.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 windows 6 | 7 | package svc 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | // event represents auto-reset, initially non-signaled Windows event. 16 | // It is used to communicate between go and asm parts of this package. 17 | type event struct { 18 | h windows.Handle 19 | } 20 | 21 | func newEvent() (*event, error) { 22 | h, err := windows.CreateEvent(nil, 0, 0, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return &event{h: h}, nil 27 | } 28 | 29 | func (e *event) Close() error { 30 | return windows.CloseHandle(e.h) 31 | } 32 | 33 | func (e *event) Set() error { 34 | return windows.SetEvent(e.h) 35 | } 36 | 37 | func (e *event) Wait() error { 38 | s, err := windows.WaitForSingleObject(e.h, windows.INFINITE) 39 | switch s { 40 | case windows.WAIT_OBJECT_0: 41 | break 42 | case windows.WAIT_FAILED: 43 | return err 44 | default: 45 | return errors.New("unexpected result from WaitForSingleObject") 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/beep.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/install.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "path/filepath" 13 | 14 | "golang.org/x/sys/windows/svc/eventlog" 15 | "golang.org/x/sys/windows/svc/mgr" 16 | ) 17 | 18 | func exePath() (string, error) { 19 | prog := os.Args[0] 20 | p, err := filepath.Abs(prog) 21 | if err != nil { 22 | return "", err 23 | } 24 | fi, err := os.Stat(p) 25 | if err == nil { 26 | if !fi.Mode().IsDir() { 27 | return p, nil 28 | } 29 | err = fmt.Errorf("%s is directory", p) 30 | } 31 | if filepath.Ext(p) == "" { 32 | p += ".exe" 33 | fi, err := os.Stat(p) 34 | if err == nil { 35 | if !fi.Mode().IsDir() { 36 | return p, nil 37 | } 38 | err = fmt.Errorf("%s is directory", p) 39 | } 40 | } 41 | return "", err 42 | } 43 | 44 | func installService(name, desc string) error { 45 | exepath, err := exePath() 46 | if err != nil { 47 | return err 48 | } 49 | m, err := mgr.Connect() 50 | if err != nil { 51 | return err 52 | } 53 | defer m.Disconnect() 54 | s, err := m.OpenService(name) 55 | if err == nil { 56 | s.Close() 57 | return fmt.Errorf("service %s already exists", name) 58 | } 59 | s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started") 60 | if err != nil { 61 | return err 62 | } 63 | defer s.Close() 64 | err = eventlog.InstallAsEventCreate(name, eventlog.Error|eventlog.Warning|eventlog.Info) 65 | if err != nil { 66 | s.Delete() 67 | return fmt.Errorf("SetupEventLogSource() failed: %s", err) 68 | } 69 | return nil 70 | } 71 | 72 | func removeService(name string) error { 73 | m, err := mgr.Connect() 74 | if err != nil { 75 | return err 76 | } 77 | defer m.Disconnect() 78 | s, err := m.OpenService(name) 79 | if err != nil { 80 | return fmt.Errorf("service %s is not installed", name) 81 | } 82 | defer s.Close() 83 | err = s.Delete() 84 | if err != nil { 85 | return err 86 | } 87 | err = eventlog.Remove(name) 88 | if err != nil { 89 | return fmt.Errorf("RemoveEventLogSource() failed: %s", err) 90 | } 91 | return nil 92 | } 93 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/main.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 windows 6 | 7 | // Example service program that beeps. 8 | // 9 | // The program demonstrates how to create Windows service and 10 | // install / remove it on a computer. It also shows how to 11 | // stop / start / pause / continue any service, and how to 12 | // write to event log. It also shows how to use debug 13 | // facilities available in debug package. 14 | // 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "log" 20 | "os" 21 | "strings" 22 | 23 | "golang.org/x/sys/windows/svc" 24 | ) 25 | 26 | func usage(errmsg string) { 27 | fmt.Fprintf(os.Stderr, 28 | "%s\n\n"+ 29 | "usage: %s \n"+ 30 | " where is one of\n"+ 31 | " install, remove, debug, start, stop, pause or continue.\n", 32 | errmsg, os.Args[0]) 33 | os.Exit(2) 34 | } 35 | 36 | func main() { 37 | const svcName = "myservice" 38 | 39 | isIntSess, err := svc.IsAnInteractiveSession() 40 | if err != nil { 41 | log.Fatalf("failed to determine if we are running in an interactive session: %v", err) 42 | } 43 | if !isIntSess { 44 | runService(svcName, false) 45 | return 46 | } 47 | 48 | if len(os.Args) < 2 { 49 | usage("no command specified") 50 | } 51 | 52 | cmd := strings.ToLower(os.Args[1]) 53 | switch cmd { 54 | case "debug": 55 | runService(svcName, true) 56 | return 57 | case "install": 58 | err = installService(svcName, "my service") 59 | case "remove": 60 | err = removeService(svcName) 61 | case "start": 62 | err = startService(svcName) 63 | case "stop": 64 | err = controlService(svcName, svc.Stop, svc.Stopped) 65 | case "pause": 66 | err = controlService(svcName, svc.Pause, svc.Paused) 67 | case "continue": 68 | err = controlService(svcName, svc.Continue, svc.Running) 69 | default: 70 | usage(fmt.Sprintf("invalid command %s", cmd)) 71 | } 72 | if err != nil { 73 | log.Fatalf("failed to %s %s: %v", cmd, svcName, err) 74 | } 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/manage.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "golang.org/x/sys/windows/svc" 14 | "golang.org/x/sys/windows/svc/mgr" 15 | ) 16 | 17 | func startService(name string) error { 18 | m, err := mgr.Connect() 19 | if err != nil { 20 | return err 21 | } 22 | defer m.Disconnect() 23 | s, err := m.OpenService(name) 24 | if err != nil { 25 | return fmt.Errorf("could not access service: %v", err) 26 | } 27 | defer s.Close() 28 | err = s.Start("is", "manual-started") 29 | if err != nil { 30 | return fmt.Errorf("could not start service: %v", err) 31 | } 32 | return nil 33 | } 34 | 35 | func controlService(name string, c svc.Cmd, to svc.State) error { 36 | m, err := mgr.Connect() 37 | if err != nil { 38 | return err 39 | } 40 | defer m.Disconnect() 41 | s, err := m.OpenService(name) 42 | if err != nil { 43 | return fmt.Errorf("could not access service: %v", err) 44 | } 45 | defer s.Close() 46 | status, err := s.Control(c) 47 | if err != nil { 48 | return fmt.Errorf("could not send control=%d: %v", c, err) 49 | } 50 | timeout := time.Now().Add(10 * time.Second) 51 | for status.State != to { 52 | if timeout.Before(time.Now()) { 53 | return fmt.Errorf("timeout waiting for service to go to state=%d", to) 54 | } 55 | time.Sleep(300 * time.Millisecond) 56 | status, err = s.Query() 57 | if err != nil { 58 | return fmt.Errorf("could not retrieve service status: %v", err) 59 | } 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 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 windows 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.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 windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go13.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 windows 6 | // +build go1.3 7 | 8 | package svc 9 | 10 | import "unsafe" 11 | 12 | const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 | 14 | // Should be a built-in for unsafe.Pointer? 15 | func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 16 | return unsafe.Pointer(uintptr(p) + x) 17 | } 18 | 19 | // funcPC returns the entry PC of the function f. 20 | // It assumes that f is a func value. Otherwise the behavior is undefined. 21 | func funcPC(f interface{}) uintptr { 22 | return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) 23 | } 24 | 25 | // from sys_386.s and sys_amd64.s 26 | func servicectlhandler(ctl uint32) uintptr 27 | func servicemain(argc uint32, argv **uint16) 28 | 29 | func getServiceMain(r *uintptr) { 30 | *r = funcPC(servicemain) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/mgr/service.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 windows 6 | 7 | package mgr 8 | 9 | import ( 10 | "syscall" 11 | 12 | "golang.org/x/sys/windows" 13 | "golang.org/x/sys/windows/svc" 14 | ) 15 | 16 | // TODO(brainman): Use EnumDependentServices to enumerate dependent services. 17 | 18 | // TODO(brainman): Use EnumServicesStatus to enumerate services in the specified service control manager database. 19 | 20 | // Service is used to access Windows service. 21 | type Service struct { 22 | Name string 23 | Handle windows.Handle 24 | } 25 | 26 | // Delete marks service s for deletion from the service control manager database. 27 | func (s *Service) Delete() error { 28 | return windows.DeleteService(s.Handle) 29 | } 30 | 31 | // Close relinquish access to the service s. 32 | func (s *Service) Close() error { 33 | return windows.CloseServiceHandle(s.Handle) 34 | } 35 | 36 | // Start starts service s. 37 | // args will be passed to svc.Handler.Execute. 38 | func (s *Service) Start(args ...string) error { 39 | var p **uint16 40 | if len(args) > 0 { 41 | vs := make([]*uint16, len(args)) 42 | for i, _ := range vs { 43 | vs[i] = syscall.StringToUTF16Ptr(args[i]) 44 | } 45 | p = &vs[0] 46 | } 47 | return windows.StartService(s.Handle, uint32(len(args)), p) 48 | } 49 | 50 | // Control sends state change request c to the servce s. 51 | func (s *Service) Control(c svc.Cmd) (svc.Status, error) { 52 | var t windows.SERVICE_STATUS 53 | err := windows.ControlService(s.Handle, uint32(c), &t) 54 | if err != nil { 55 | return svc.Status{}, err 56 | } 57 | return svc.Status{ 58 | State: svc.State(t.CurrentState), 59 | Accepts: svc.Accepted(t.ControlsAccepted), 60 | }, nil 61 | } 62 | 63 | // Query returns current status of service s. 64 | func (s *Service) Query() (svc.Status, error) { 65 | var t windows.SERVICE_STATUS 66 | err := windows.QueryServiceStatus(s.Handle, &t) 67 | if err != nil { 68 | return svc.Status{}, err 69 | } 70 | return svc.Status{ 71 | State: svc.State(t.CurrentState), 72 | Accepts: svc.Accepted(t.ControlsAccepted), 73 | }, nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/security.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 windows 6 | 7 | package svc 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | func allocSid(subAuth0 uint32) (*windows.SID, error) { 16 | var sid *windows.SID 17 | err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY, 18 | 1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return sid, nil 23 | } 24 | 25 | // IsAnInteractiveSession determines if calling process is running interactively. 26 | // It queries the process token for membership in the Interactive group. 27 | // http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s 28 | func IsAnInteractiveSession() (bool, error) { 29 | interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID) 30 | if err != nil { 31 | return false, err 32 | } 33 | defer windows.FreeSid(interSid) 34 | 35 | serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID) 36 | if err != nil { 37 | return false, err 38 | } 39 | defer windows.FreeSid(serviceSid) 40 | 41 | t, err := windows.OpenCurrentProcessToken() 42 | if err != nil { 43 | return false, err 44 | } 45 | defer t.Close() 46 | 47 | gs, err := t.GetTokenGroups() 48 | if err != nil { 49 | return false, err 50 | } 51 | p := unsafe.Pointer(&gs.Groups[0]) 52 | groups := (*[2 << 20]windows.SIDAndAttributes)(p)[:gs.GroupCount] 53 | for _, g := range groups { 54 | if windows.EqualSid(g.Sid, interSid) { 55 | return true, nil 56 | } 57 | if windows.EqualSid(g.Sid, serviceSid) { 58 | return false, nil 59 | } 60 | } 61 | return false, nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_386.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 windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL argc+0(FP), AX 10 | MOVL AX, ·sArgc(SB) 11 | MOVL argv+4(FP), AX 12 | MOVL AX, ·sArgv(SB) 13 | 14 | PUSHL BP 15 | PUSHL BX 16 | PUSHL SI 17 | PUSHL DI 18 | 19 | SUBL $12, SP 20 | 21 | MOVL ·sName(SB), AX 22 | MOVL AX, (SP) 23 | MOVL $·servicectlhandler(SB), AX 24 | MOVL AX, 4(SP) 25 | MOVL ·cRegisterServiceCtrlHandlerW(SB), AX 26 | MOVL SP, BP 27 | CALL AX 28 | MOVL BP, SP 29 | CMPL AX, $0 30 | JE exit 31 | MOVL AX, ·ssHandle(SB) 32 | 33 | MOVL ·goWaitsH(SB), AX 34 | MOVL AX, (SP) 35 | MOVL ·cSetEvent(SB), AX 36 | MOVL SP, BP 37 | CALL AX 38 | MOVL BP, SP 39 | 40 | MOVL ·cWaitsH(SB), AX 41 | MOVL AX, (SP) 42 | MOVL $-1, AX 43 | MOVL AX, 4(SP) 44 | MOVL ·cWaitForSingleObject(SB), AX 45 | MOVL SP, BP 46 | CALL AX 47 | MOVL BP, SP 48 | 49 | exit: 50 | ADDL $12, SP 51 | 52 | POPL DI 53 | POPL SI 54 | POPL BX 55 | POPL BP 56 | 57 | MOVL 0(SP), CX 58 | ADDL $12, SP 59 | JMP CX 60 | 61 | // I do not know why, but this seems to be the only way to call 62 | // ctlHandlerProc on Windows 7. 63 | 64 | // func servicectlhandler(ctl uint32) uintptr 65 | TEXT ·servicectlhandler(SB),7,$0 66 | MOVL ·ctlHandlerProc(SB), CX 67 | JMP CX 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL CX, ·sArgc(SB) 10 | MOVL DX, ·sArgv(SB) 11 | 12 | SUBQ $32, SP // stack for the first 4 syscall params 13 | 14 | MOVQ ·sName(SB), CX 15 | MOVQ $·servicectlhandler(SB), DX 16 | MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX 17 | CALL AX 18 | CMPQ AX, $0 19 | JE exit 20 | MOVQ AX, ·ssHandle(SB) 21 | 22 | MOVQ ·goWaitsH(SB), CX 23 | MOVQ ·cSetEvent(SB), AX 24 | CALL AX 25 | 26 | MOVQ ·cWaitsH(SB), CX 27 | MOVQ $4294967295, DX 28 | MOVQ ·cWaitForSingleObject(SB), AX 29 | CALL AX 30 | 31 | exit: 32 | ADDQ $32, SP 33 | RET 34 | 35 | // I do not know why, but this seems to be the only way to call 36 | // ctlHandlerProc on Windows 7. 37 | 38 | // func servicectlhandler(ctl uint32) uintptr 39 | TEXT ·servicectlhandler(SB),7,$0 40 | MOVQ ·ctlHandlerProc(SB), AX 41 | JMP AX 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /vendor/gopkg.in/airbrake/gobrake.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The Gobrake 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/gopkg.in/airbrake/gobrake.v2/gobrake.go: -------------------------------------------------------------------------------- 1 | package gobrake 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | var logger *log.Logger 9 | 10 | func init() { 11 | SetLogger(log.New(os.Stderr, "gobrake: ", log.LstdFlags)) 12 | } 13 | 14 | func SetLogger(l *log.Logger) { 15 | logger = l 16 | } 17 | -------------------------------------------------------------------------------- /vendor/gopkg.in/airbrake/gobrake.v2/util.go: -------------------------------------------------------------------------------- 1 | package gobrake 2 | 3 | import ( 4 | "runtime" 5 | "strings" 6 | ) 7 | 8 | func stackFilter(packageName, funcName string, file string, line int) bool { 9 | return packageName == "runtime" && funcName == "panic" 10 | } 11 | 12 | type StackFrame struct { 13 | File string `json:"file"` 14 | Line int `json:"line"` 15 | Func string `json:"function"` 16 | } 17 | 18 | func stack(depth int) []StackFrame { 19 | stack := []StackFrame{} 20 | for i := depth; ; i++ { 21 | pc, file, line, ok := runtime.Caller(i) 22 | if !ok { 23 | break 24 | } 25 | packageName, funcName := packageFuncName(pc) 26 | if stackFilter(packageName, funcName, file, line) { 27 | stack = stack[:0] 28 | continue 29 | } 30 | stack = append(stack, StackFrame{ 31 | File: file, 32 | Line: line, 33 | Func: funcName, 34 | }) 35 | } 36 | 37 | return stack 38 | } 39 | 40 | func packageFuncName(pc uintptr) (string, string) { 41 | f := runtime.FuncForPC(pc) 42 | if f == nil { 43 | return "", "" 44 | } 45 | 46 | packageName := "" 47 | funcName := f.Name() 48 | 49 | if ind := strings.LastIndex(funcName, "/"); ind > 0 { 50 | packageName += funcName[:ind+1] 51 | funcName = funcName[ind+1:] 52 | } 53 | if ind := strings.Index(funcName, "."); ind > 0 { 54 | packageName += funcName[:ind] 55 | funcName = funcName[ind+1:] 56 | } 57 | 58 | return packageName, funcName 59 | } 60 | -------------------------------------------------------------------------------- /vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Gemnasium 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/gopkg.in/gemnasium/logrus-airbrake-hook.v2/airbrake.go: -------------------------------------------------------------------------------- 1 | package airbrake // import "gopkg.in/gemnasium/logrus-airbrake-hook.v2" 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/http" 7 | "os" 8 | 9 | "github.com/Sirupsen/logrus" 10 | "gopkg.in/airbrake/gobrake.v2" 11 | ) 12 | 13 | // AirbrakeHook to send exceptions to an exception-tracking service compatible 14 | // with the Airbrake API. 15 | type airbrakeHook struct { 16 | Airbrake *gobrake.Notifier 17 | } 18 | 19 | func NewHook(projectID int64, apiKey, env string) *airbrakeHook { 20 | airbrake := gobrake.NewNotifier(projectID, apiKey) 21 | airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice { 22 | if env == "development" { 23 | return nil 24 | } 25 | notice.Context["environment"] = env 26 | return notice 27 | }) 28 | hook := &airbrakeHook{ 29 | Airbrake: airbrake, 30 | } 31 | return hook 32 | } 33 | 34 | func (hook *airbrakeHook) Fire(entry *logrus.Entry) error { 35 | var notifyErr error 36 | err, ok := entry.Data["error"].(error) 37 | if ok { 38 | notifyErr = err 39 | } else { 40 | notifyErr = errors.New(entry.Message) 41 | } 42 | var req *http.Request 43 | for k, v := range entry.Data { 44 | if r, ok := v.(*http.Request); ok { 45 | req = r 46 | delete(entry.Data, k) 47 | break 48 | } 49 | } 50 | notice := hook.Airbrake.Notice(notifyErr, req, 3) 51 | for k, v := range entry.Data { 52 | notice.Context[k] = fmt.Sprintf("%s", v) 53 | } 54 | 55 | hook.sendNotice(notice) 56 | return nil 57 | } 58 | 59 | func (hook *airbrakeHook) sendNotice(notice *gobrake.Notice) { 60 | if _, err := hook.Airbrake.SendNotice(notice); err != nil { 61 | fmt.Fprintf(os.Stderr, "Failed to send error to Airbrake: %v\n", err) 62 | } 63 | } 64 | 65 | func (hook *airbrakeHook) Levels() []logrus.Level { 66 | return []logrus.Level{ 67 | logrus.ErrorLevel, 68 | logrus.FatalLevel, 69 | logrus.PanicLevel, 70 | } 71 | } 72 | --------------------------------------------------------------------------------