├── .gitignore ├── .tmp └── .gitignore ├── .travis.yml ├── GPL3_LICENSE.md ├── LICENSE.md ├── Makefile ├── README.md ├── cloudwatch.go ├── cloudwatch_test.go ├── config.go ├── config.ini ├── config_test.go ├── debug.go ├── errors.go ├── fixtures_test.go ├── logging.go ├── main.go ├── parsers.go ├── parsers_test.go ├── queue.go ├── queue_test.go ├── receivers.go ├── release.go ├── syslog.go ├── syslog_test.go └── vendor ├── github.com ├── Sirupsen │ └── logrus │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── alt_exit.go │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── hooks │ │ └── syslog │ │ │ ├── README.md │ │ │ └── syslog.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 ├── aws │ └── aws-sdk-go │ │ ├── LICENSE.txt │ │ ├── NOTICE.txt │ │ ├── aws │ │ ├── awserr │ │ │ ├── error.go │ │ │ └── types.go │ │ ├── awsutil │ │ │ ├── copy.go │ │ │ ├── equal.go │ │ │ ├── path_value.go │ │ │ ├── prettify.go │ │ │ └── string_value.go │ │ ├── client │ │ │ ├── client.go │ │ │ ├── default_retryer.go │ │ │ └── metadata │ │ │ │ └── client_info.go │ │ ├── config.go │ │ ├── convert_types.go │ │ ├── corehandlers │ │ │ ├── handlers.go │ │ │ └── param_validator.go │ │ ├── credentials │ │ │ ├── chain_provider.go │ │ │ ├── credentials.go │ │ │ ├── ec2rolecreds │ │ │ │ └── ec2_role_provider.go │ │ │ ├── endpointcreds │ │ │ │ └── provider.go │ │ │ ├── env_provider.go │ │ │ ├── example.ini │ │ │ ├── shared_credentials_provider.go │ │ │ ├── static_provider.go │ │ │ └── stscreds │ │ │ │ └── assume_role_provider.go │ │ ├── defaults │ │ │ └── defaults.go │ │ ├── ec2metadata │ │ │ ├── api.go │ │ │ └── service.go │ │ ├── endpoints │ │ │ ├── decode.go │ │ │ ├── defaults.go │ │ │ ├── doc.go │ │ │ ├── endpoints.go │ │ │ ├── v3model.go │ │ │ └── v3model_codegen.go │ │ ├── errors.go │ │ ├── logger.go │ │ ├── request │ │ │ ├── handlers.go │ │ │ ├── http_request.go │ │ │ ├── offset_reader.go │ │ │ ├── request.go │ │ │ ├── request_1_7.go │ │ │ ├── request_1_8.go │ │ │ ├── request_pagination.go │ │ │ ├── retryer.go │ │ │ └── validation.go │ │ ├── session │ │ │ ├── doc.go │ │ │ ├── env_config.go │ │ │ ├── session.go │ │ │ └── shared_config.go │ │ ├── signer │ │ │ └── v4 │ │ │ │ ├── header_rules.go │ │ │ │ ├── uri_path.go │ │ │ │ └── v4.go │ │ ├── types.go │ │ └── version.go │ │ ├── private │ │ └── protocol │ │ │ ├── idempotency.go │ │ │ ├── json │ │ │ └── jsonutil │ │ │ │ ├── build.go │ │ │ │ └── unmarshal.go │ │ │ ├── jsonrpc │ │ │ └── jsonrpc.go │ │ │ ├── query │ │ │ ├── build.go │ │ │ ├── queryutil │ │ │ │ └── queryutil.go │ │ │ ├── unmarshal.go │ │ │ └── unmarshal_error.go │ │ │ ├── rest │ │ │ ├── build.go │ │ │ ├── payload.go │ │ │ └── unmarshal.go │ │ │ ├── unmarshal.go │ │ │ └── xml │ │ │ └── xmlutil │ │ │ ├── build.go │ │ │ ├── unmarshal.go │ │ │ └── xml_to_struct.go │ │ └── service │ │ ├── cloudwatchlogs │ │ ├── api.go │ │ └── service.go │ │ └── sts │ │ ├── api.go │ │ ├── customizations.go │ │ └── service.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── go-ini │ └── ini │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── README_ZH.md │ │ ├── error.go │ │ ├── ini.go │ │ ├── key.go │ │ ├── parser.go │ │ ├── section.go │ │ └── struct.go ├── jmespath │ └── go-jmespath │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── api.go │ │ ├── astnodetype_string.go │ │ ├── functions.go │ │ ├── interpreter.go │ │ ├── lexer.go │ │ ├── parser.go │ │ ├── toktype_string.go │ │ └── util.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go └── stretchr │ └── testify │ ├── LICENSE │ └── assert │ ├── assertion_forward.go │ ├── assertion_forward.go.tmpl │ ├── assertions.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ └── http_assertions.go ├── golang.org └── x │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── gccgo_linux_sparc64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_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 │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_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_mips64.go │ ├── zsyscall_linux_mips64le.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_mips64.go │ ├── zsysnum_linux_mips64le.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_mips64.go │ ├── ztypes_linux_mips64le.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 └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | dist 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | -------------------------------------------------------------------------------- /.tmp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | notifications: 2 | email: 3 | on_success: change 4 | on_failure: change 5 | 6 | 7 | language: go 8 | 9 | go: 10 | - 1.7 11 | - 1.8 12 | 13 | before_install: 14 | - make dep 15 | 16 | script: 17 | - make test 18 | 19 | after_success: 20 | - make coveralls 21 | 22 | before_deploy: 23 | - make dist 24 | 25 | deploy: 26 | provider: releases 27 | api_key: $GITHUB_TOKEN 28 | file_glob: true 29 | file: dist/* 30 | skip_cleanup: true 31 | on: 32 | tags: true 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION?=$(shell git describe --tags --always) 2 | GO_FILES:=$(shell find . -not -path "./vendor/*" -name "*.go") 3 | GO_PROGRAM_FILES:=$(shell find . -not -path "./vendor/*" -not -name "*_test.go" -name "*.go") 4 | GOIMPORTS?=$(shell goimports -d $(GO_FILES) | tee /dev/stderr) 5 | TMP_DIR:=.tmp 6 | BUILD_DIR:=dist 7 | BUILD_OS:="linux freebsd" 8 | BUILD_ARCH:="amd64 386" 9 | BIN_NAME:=awslogs 10 | 11 | LD_FLAGS:="-X main.version=$(VERSION)" 12 | 13 | PKG_gox=github.com/mitchellh/gox 14 | PKG_goveralls=github.com/mattn/goveralls 15 | PKG_goimports=golang.org/x/tools/cmd/goimports 16 | 17 | .DEFAULT_GOAL := bin 18 | 19 | coveralls: dep 20 | @goveralls -service=travis-ci 21 | 22 | dep: 23 | @go get \ 24 | $(PKG_goimports) \ 25 | $(PKG_goveralls) \ 26 | $(PKG_gox) 27 | 28 | bin: 29 | @go build \ 30 | -race \ 31 | -tags debug \ 32 | -o $(TMP_DIR)/$(BIN_NAME) \ 33 | -ldflags $(LD_FLAGS) 34 | 35 | run: bin 36 | @$(TMP_DIR)/$(BIN_NAME) 37 | 38 | test: dep 39 | @if [ "$(GOIMPORTS)" ]; then exit 1; fi 40 | @go vet 41 | @go test -race 42 | 43 | dist: dep distclean 44 | @gox \ 45 | -os=$(BUILD_OS) \ 46 | -arch=$(BUILD_ARCH) \ 47 | -output "$(BUILD_DIR)/{{.OS}}_{{.Arch}}_$(BIN_NAME)" \ 48 | -ldflags $(LD_FLAGS) 49 | 50 | distclean: 51 | @rm -f $(BUILD_DIR)/* 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/ClearcodeHQ/Go-Forward.svg)](https://travis-ci.org/ClearcodeHQ/Go-Forward) 2 | [![Coverage Status](https://coveralls.io/repos/github/ClearcodeHQ/Go-Forward/badge.svg?branch=master)](https://coveralls.io/github/ClearcodeHQ/Go-Forward?branch=master) 3 | 4 | This program's purpose is to forward all logs received from a unix/ip socket and forward them to cloudwatch logs. 5 | 6 | ### Motivation: 7 | * Learn go 8 | * Small memory footprint 9 | * No file readers 10 | * Socket listeners 11 | 12 | ### Usage: 13 | ``` 14 | -c string 15 | Config file location. (default "/etc/logs_agent.cfg") 16 | ``` 17 | See [config.ini](config.ini) for possible configuration options. 18 | 19 | ### Program behaviour: 20 | * Logs that are too old are discarded. 21 | * Logs that exceed their allowed size are discarded. 22 | * Incoming message timestamps are only used to set cloudwatch logs 23 | timestamp value. They are not written in message body. 24 | -------------------------------------------------------------------------------- /cloudwatch_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func Test_logEvent_size(t *testing.T) { 10 | event := logEvent{msg: "123", timestamp: 123} 11 | expected := 3 + eventSizeOverhead 12 | assert.Equal(t, expected, event.size()) 13 | } 14 | 15 | func Test_logEvent_tooBig(t *testing.T) { 16 | event := logEvent{msg: RandomString(maxEventSize + 1)} 17 | assert.Equal(t, errMessageTooBig, event.validate()) 18 | } 19 | 20 | func Test_destination_string(t *testing.T) { 21 | dst := destination{group: "group", stream: "stream"} 22 | assert.Equal(t, "group: group stream: stream", dst.String()) 23 | } 24 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [main] 2 | log_output=syslog 3 | log_level=error 4 | 5 | ;; Unique section name 6 | [app-logs] 7 | ;; Cloudwatch group name 8 | group = app 9 | ;; Cloudwatch stream name. Available variables: 10 | ;; Hostname, InstanceID 11 | stream = logs 12 | ;; Socket URL to listen on. Supported sockets: 13 | ; - UDP 14 | source = udp://localhost:5514 15 | ;; Syslog message format. Available formats: 16 | ;; - RFC3164 17 | syslog_format = RFC3164 18 | ;; Outgoing message format. Available fields: 19 | ;; Facility, Severity, Hostname, Sslogtag, Message 20 | ;; All specified fileds will be replaced by their value. 21 | cloudwatch_format = {{.Facility}} {{.Severity}} {{.Hostname}} {{.Syslogtag}} {{.Message}} 22 | ;; How much messages can be queued in buffer. Must be >= 0. If set to 0 then all messages will be discarded. 23 | ;; When limit is reached, all incomming messages will be discarded. 24 | ;; Defaults to 50000 25 | ;queue_size = 50000 26 | ;; Delay in milliseconds to wait between upload to cloudwatch. 27 | ;; Defaults to 200 28 | ;upload_delay = 200 29 | -------------------------------------------------------------------------------- /config_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestValidateGroup_valid_chars(t *testing.T) { 10 | err := validateGroup("_-/.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") 11 | assert.Nil(t, err) 12 | } 13 | 14 | func TestValidateGroup_too_long(t *testing.T) { 15 | err := validateGroup(RandomString(518)) 16 | assert.Equal(t, err, errNameTooLong) 17 | } 18 | 19 | func TestValidateGroup_empty(t *testing.T) { 20 | err := validateGroup("") 21 | assert.Equal(t, errEmptyValue, err) 22 | } 23 | 24 | func TestValidateGroup_invalid_strings(t *testing.T) { 25 | for _, chr := range []string{",", "|", "ą"} { 26 | err := validateGroup(chr) 27 | assert.Equal(t, err, errInvalidValue) 28 | } 29 | } 30 | 31 | func TestValidateStream_too_long(t *testing.T) { 32 | err := validateStrean(RandomString(518)) 33 | assert.Equal(t, err, errNameTooLong) 34 | } 35 | 36 | func TestValidateStream_empty(t *testing.T) { 37 | err := validateStrean("") 38 | assert.Equal(t, errEmptyValue, err) 39 | } 40 | 41 | func TestValidateStream_invalid_strings(t *testing.T) { 42 | err := validateGroup(":") 43 | assert.Equal(t, err, errInvalidValue) 44 | } 45 | 46 | func TestValidateSource_ok(t *testing.T) { 47 | for _, uri := range []string{ 48 | "udp://localhost:5514", 49 | } { 50 | err := validateSource(uri) 51 | assert.Nil(t, err) 52 | } 53 | } 54 | 55 | func TestValidateSource_error(t *testing.T) { 56 | for uri, expected := range map[string]error{ 57 | "tcp://localhost:5514": errInvalidScheme, 58 | } { 59 | err := validateSource(uri) 60 | assert.Equal(t, err, expected) 61 | } 62 | } 63 | 64 | func Test_validateSyslogFormat_empty(t *testing.T) { 65 | err := validateSyslogFormat("") 66 | assert.Equal(t, errEmptyValue, err) 67 | } 68 | 69 | func Test_validateSyslogFormat_format(t *testing.T) { 70 | err := validateSyslogFormat("bad_format") 71 | assert.Equal(t, errInvalidFormat, err) 72 | } 73 | 74 | func Test_validateCloudwatchFormat_empty(t *testing.T) { 75 | err := validateCloudwatchFormat("") 76 | assert.Equal(t, errEmptyValue, err) 77 | } 78 | 79 | func Test_validateLogOutput_empty(t *testing.T) { 80 | err := validateLogOutput("") 81 | assert.Equal(t, errEmptyValue, err) 82 | } 83 | 84 | func Test_validateLogLevel_empty(t *testing.T) { 85 | err := validateLogLevel("") 86 | assert.Equal(t, errEmptyValue, err) 87 | } 88 | 89 | func Test_validateLogOutput_invalid(t *testing.T) { 90 | err := validateLogOutput("invalid") 91 | assert.Equal(t, errInvalidValue, err) 92 | } 93 | 94 | func Test_validateLogLevel_invalid(t *testing.T) { 95 | err := validateLogLevel("invalid") 96 | assert.Equal(t, errInvalidValue, err) 97 | } 98 | 99 | func Test_validateLogLevel_ok(t *testing.T) { 100 | for _, option := range validLevelOptions { 101 | assert.Nil(t, validateLogLevel(option)) 102 | } 103 | } 104 | 105 | func Test_validateLogOutput_ok(t *testing.T) { 106 | for _, option := range validOutputOptions { 107 | assert.Nil(t, validateLogOutput(option)) 108 | } 109 | } 110 | 111 | func Test_validateStrContains_false(t *testing.T) { 112 | assert.False(t, strIn([]string{}, "needle")) 113 | } 114 | 115 | func Test_validateStrContains_true(t *testing.T) { 116 | assert.True(t, strIn([]string{"needle"}, "needle")) 117 | } 118 | 119 | func Test_validateUploadDelay_ok(t *testing.T) { 120 | assert.Nil(t, validateUploadDelay(300)) 121 | } 122 | 123 | func Test_validateUploadDelay_too_small(t *testing.T) { 124 | assert.Equal(t, errTooSmall, validateUploadDelay(1)) 125 | } 126 | 127 | func Test_validateQueueSize_ok(t *testing.T) { 128 | assert.Nil(t, validateQueueSize(0)) 129 | } 130 | -------------------------------------------------------------------------------- /debug.go: -------------------------------------------------------------------------------- 1 | // +build debug 2 | 3 | package main 4 | 5 | import ( 6 | "net/http" 7 | _ "net/http/pprof" 8 | ) 9 | 10 | func debug() { 11 | go func() { 12 | http.ListenAndServe("localhost:6060", nil) 13 | }() 14 | } 15 | -------------------------------------------------------------------------------- /errors.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var ( 8 | errMessageTooBig = errors.New("message is too big") 9 | errUnknownMessageFormat = errors.New("unknown syslog message format") 10 | errEmptyMessage = errors.New("message is empty") 11 | errEmptyValue = errors.New("empty value") 12 | errInvalidValue = errors.New("invalid value") 13 | errNameTooLong = errors.New("name too long") 14 | errInvalidScheme = errors.New("invalid network scheme") 15 | errInvalidFormat = errors.New("invalid format") 16 | errTooSmall = errors.New("too small value") 17 | ) 18 | -------------------------------------------------------------------------------- /fixtures_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | 7 | "github.com/go-ini/ini" 8 | ) 9 | 10 | type numPair struct { 11 | expected int 12 | passed int 13 | } 14 | 15 | // Create a N long random string 16 | func RandomString(strlen int) string { 17 | rand.Seed(time.Now().UTC().UnixNano()) 18 | const chars = "abcdefghijklmnopqrstuvwxyz0123456789" 19 | result := make([]byte, strlen) 20 | for i := 0; i < strlen; i++ { 21 | result[i] = chars[rand.Intn(len(chars))] 22 | } 23 | return string(result) 24 | } 25 | 26 | func empty_ini_section() *ini.Section { 27 | i, _ := ini.Load([]byte("")) 28 | i.DeleteSection(ini.DEFAULT_SECTION) 29 | sec, _ := i.NewSection("fixture") 30 | return sec 31 | } 32 | 33 | var testPriorities = []TestSyslogPriority{ 34 | {severity: logErr, facility: logMail, priority: SyslogPriority(19)}, 35 | {severity: logEmerg, facility: logKern, priority: SyslogPriority(0)}, 36 | {severity: logAlert, facility: logUser, priority: SyslogPriority(9)}, 37 | } 38 | -------------------------------------------------------------------------------- /logging.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "log/syslog" 7 | "os" 8 | 9 | log "github.com/Sirupsen/logrus" 10 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 11 | ) 12 | 13 | type writerHook struct { 14 | out io.Writer 15 | } 16 | 17 | func (hook *writerHook) Fire(entry *log.Entry) error { 18 | line, _ := entry.String() 19 | io.WriteString(hook.out, line) 20 | return nil 21 | } 22 | 23 | func (hook *writerHook) Levels() []log.Level { 24 | return log.AllLevels 25 | } 26 | 27 | type programFormat struct{} 28 | 29 | func (f *programFormat) Format(e *log.Entry) ([]byte, error) { 30 | buf := []byte(e.Message) 31 | buf = append(buf, byte('\n')) 32 | return buf, nil 33 | } 34 | 35 | func pickHook(out logoutput) log.Hook { 36 | switch out { 37 | case sysLog: 38 | hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_DAEMON, "awslogs") 39 | if err != nil { 40 | log.Fatal("Unable to connect to local syslog daemon") 41 | } 42 | return hook 43 | case stdOut: 44 | return &writerHook{out: os.Stdout} 45 | case stdErr: 46 | return &writerHook{out: os.Stderr} 47 | case null: 48 | return &writerHook{out: ioutil.Discard} 49 | default: 50 | return &writerHook{out: os.Stderr} 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /parsers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | type syslogParser func(msg string) (syslogMessage, error) 10 | 11 | var parserFunctions = map[string]syslogParser{ 12 | "RFC3164": parseRFC3164, 13 | } 14 | 15 | // https://tools.ietf.org/html/rfc3164 16 | func parseRFC3164(str string) (parsed syslogMessage, err error) { 17 | str = strings.Replace(str, "<", "", 1) 18 | str = strings.Replace(str, ">", " ", 1) 19 | str = strings.Replace(str, " ", " ", 1) 20 | strs := strings.SplitN(str, " ", 7) 21 | if len(strs) != 7 { 22 | err = errUnknownMessageFormat 23 | return 24 | } 25 | 26 | priority, err := strconv.Atoi(strs[0]) 27 | if err != nil { 28 | return 29 | } 30 | fac, sev := SyslogPriority(priority).decode() 31 | parsed.Facility = fac 32 | parsed.Severity = sev 33 | 34 | date := strings.Join(strs[1:4], " ") 35 | timestamp, err := parseRFC3164Timestamp(date) 36 | if err != nil { 37 | return 38 | } 39 | parsed.timestamp = timestamp 40 | 41 | parsed.Message = strings.TrimSpace(strs[6]) 42 | if parsed.Message == "" { 43 | err = errEmptyMessage 44 | return 45 | } 46 | 47 | parsed.Syslogtag = strs[5] 48 | parsed.Hostname = strs[4] 49 | 50 | return 51 | } 52 | 53 | // https://tools.ietf.org/html/rfc3164#section-4.1.2 54 | func parseRFC3164Timestamp(timestamp string) (ts time.Time, err error) { 55 | ts, err = time.Parse(time.Stamp, timestamp) 56 | if err != nil { 57 | return 58 | } 59 | now := time.Now() 60 | ts = time.Date(now.Year(), ts.Month(), ts.Day(), ts.Hour(), ts.Minute(), 61 | ts.Second(), ts.Nanosecond(), ts.Location()) 62 | return 63 | } 64 | -------------------------------------------------------------------------------- /parsers_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func Test_Parse_RFC3164_Severity(t *testing.T) { 11 | msg := "<86>Jul 23 14:48:16 debian sudo: pam_unix(sudo:session): session closed for user root" 12 | parsed, err := parseRFC3164(msg) 13 | assert.Equal(t, logInfo, parsed.Severity) 14 | assert.Equal(t, logAuthpriv, parsed.Facility) 15 | assert.Equal(t, time.Month(7), parsed.timestamp.Month()) 16 | assert.Equal(t, "debian", parsed.Hostname) 17 | assert.Equal(t, "sudo:", parsed.Syslogtag) 18 | assert.Equal(t, "pam_unix(sudo:session): session closed for user root", parsed.Message) 19 | assert.Nil(t, err) 20 | } 21 | 22 | func Test_parseRFC3164_empty(t *testing.T) { 23 | msg := "<86>Jul 23 14:48:16 debian sudo: " 24 | _, err := parseRFC3164(msg) 25 | assert.Equal(t, err, errEmptyMessage) 26 | } 27 | 28 | func TestUnknownMessage(t *testing.T) { 29 | bad_messages := []string{ 30 | "kfjlsdkfdlsjdlfgkdlsfghsdlfgkh", 31 | "<888>dsfdsfdsgsgd", 32 | "bla bla#@$@#4", 33 | "<84>bla bla#@$@#4", 34 | } 35 | for _, msg := range bad_messages { 36 | _, err := parseRFC3164(msg) 37 | assert.Equal(t, errUnknownMessageFormat, err) 38 | } 39 | } 40 | 41 | func Benchmark_parseRCF3164(b *testing.B) { 42 | msg := "<86>Jul 23 14:48:16 debian sudo: pam_unix(sudo:session): session closed for user root" 43 | for n := 0; n < b.N; n++ { 44 | parseRFC3164(msg) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /queue.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | type eventsList []logEvent 8 | 9 | // Calculate size including each event overhead. 10 | func (m eventsList) size() (size int) { 11 | for _, elem := range m { 12 | size += elem.size() 13 | } 14 | return 15 | } 16 | 17 | func (m eventsList) Len() int { 18 | return len(m) 19 | } 20 | 21 | func (m eventsList) Swap(i, j int) { 22 | m[i], m[j] = m[j], m[i] 23 | } 24 | 25 | func (m eventsList) Less(i, j int) bool { 26 | return m[i].timestamp < m[j].timestamp 27 | } 28 | 29 | type eventQueue struct { 30 | events eventsList 31 | max_size queue_size 32 | } 33 | 34 | func (q *eventQueue) add(event ...logEvent) { 35 | left := int(q.max_size) - len(q.events) 36 | many := event[:min(left, len(event))] 37 | q.events = append(q.events, many...) 38 | } 39 | 40 | func (q *eventQueue) getBatch() (batch eventsList) { 41 | sort.Sort(q.events) 42 | index := numEvents(q.events, sizeIndex, timeIndex) 43 | batch, q.events = q.events[:index], q.events[index:] 44 | return 45 | } 46 | 47 | func (q *eventQueue) empty() bool { 48 | return len(q.events) == 0 49 | } 50 | 51 | func (q *eventQueue) num() int { 52 | return len(q.events) 53 | } 54 | 55 | // Return lowest index based on all check functions 56 | // This function assumes that events are sorted by timestamp in ascending order 57 | func numEvents(events eventsList, checkFn ...indexNumFn) int { 58 | index := maxBatchEvents 59 | for _, fn := range checkFn { 60 | result := fn(events) 61 | if result < index { 62 | index = result 63 | } 64 | } 65 | return index 66 | } 67 | 68 | type indexNumFn func(events eventsList) int 69 | 70 | // This function assumes that events are sorted by timestamp in ascending order 71 | func sizeIndex(events eventsList) int { 72 | size, index := 0, 0 73 | for i, event := range events { 74 | size += event.size() 75 | if size > maxBatchSize { 76 | break 77 | } 78 | index = i + 1 79 | } 80 | return index 81 | } 82 | 83 | // This function assumes that events are sorted by timestamp in ascending order 84 | func timeIndex(events eventsList) (index int) { 85 | first := events[0] 86 | for i, event := range events { 87 | if (event.timestamp - first.timestamp) > maxBatchTimeSpan { 88 | break 89 | } 90 | index = i + 1 91 | } 92 | return index 93 | } 94 | 95 | func min(ints ...int) int { 96 | m := ints[0] 97 | for _, i := range ints { 98 | if i < m { 99 | m = i 100 | } 101 | } 102 | return m 103 | } 104 | -------------------------------------------------------------------------------- /queue_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "sort" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func Test_queue_empty(t *testing.T) { 11 | queue := &eventQueue{max_size: 1} 12 | assert.True(t, queue.empty()) 13 | } 14 | 15 | func Test_queue_not_empty(t *testing.T) { 16 | queue := &eventQueue{max_size: 1} 17 | queue.add(logEvent{}) 18 | assert.False(t, queue.empty()) 19 | } 20 | 21 | func Test_queue_length(t *testing.T) { 22 | queue := &eventQueue{max_size: 1} 23 | queue.add(logEvent{}) 24 | assert.Equal(t, 1, queue.num()) 25 | } 26 | 27 | // Assert that event is added at the end of slice. 28 | func Test_queue_add(t *testing.T) { 29 | queue := &eventQueue{max_size: 3} 30 | queue.add(logEvent{msg: "first"}) 31 | queue.add(logEvent{msg: "second"}) 32 | queue.add(logEvent{msg: "third"}) 33 | expected := eventsList{ 34 | logEvent{msg: "first"}, 35 | logEvent{msg: "second"}, 36 | logEvent{msg: "third"}, 37 | } 38 | assert.Equal(t, expected, queue.events) 39 | } 40 | 41 | // Assert that batch is sorted. 42 | func Test_queue_sorted_batch(t *testing.T) { 43 | queue := &eventQueue{max_size: 2} 44 | queue.add(logEvent{timestamp: 2}) 45 | queue.add(logEvent{timestamp: 1}) 46 | assert.Equal(t, logEvent{timestamp: 1}, queue.getBatch()[0]) 47 | } 48 | 49 | // Assert that batch size does not exceed its allowed maximum 50 | func Test_sizeIndex_multi(t *testing.T) { 51 | events := eventsList{ 52 | logEvent{msg: RandomString(maxEventSize)}, 53 | logEvent{msg: RandomString(maxEventSize)}, 54 | logEvent{msg: RandomString(maxEventSize)}, 55 | logEvent{msg: RandomString(maxEventSize)}, 56 | } 57 | assert.Equal(t, 3, sizeIndex(events)) 58 | } 59 | 60 | // Assert that batch time span does not exceed its allowed maximum 61 | func Test_timeIndex_multi(t *testing.T) { 62 | events := eventsList{ 63 | logEvent{timestamp: maxBatchTimeSpan}, 64 | logEvent{timestamp: maxBatchTimeSpan}, 65 | logEvent{timestamp: maxBatchTimeSpan * 3}, 66 | } 67 | assert.Equal(t, 2, timeIndex(events)) 68 | } 69 | 70 | // Assert that batch time span does not exceed its allowed maximum 71 | func Test_timeIndex_single(t *testing.T) { 72 | events := eventsList{ 73 | logEvent{timestamp: maxBatchTimeSpan}, 74 | } 75 | assert.Equal(t, 1, timeIndex(events)) 76 | } 77 | 78 | // Assert that lowest index is returned 79 | func Test_numEvents_min(t *testing.T) { 80 | events := make(eventsList, 0) 81 | funcA := func(e eventsList) int { return maxBatchEvents - 1 } 82 | funcB := func(e eventsList) int { return maxBatchEvents - 2 } 83 | assert.Equal(t, maxBatchEvents-2, numEvents(events, funcA, funcB)) 84 | } 85 | 86 | // Assert that maximum index is returned 87 | func Test_numEvents_max(t *testing.T) { 88 | events := make(eventsList, 0) 89 | funcA := func(e eventsList) int { return maxBatchEvents } 90 | funcB := func(e eventsList) int { return maxBatchEvents } 91 | assert.Equal(t, maxBatchEvents, numEvents(events, funcA, funcB)) 92 | } 93 | 94 | func Test_eventList_size(t *testing.T) { 95 | events := eventsList{ 96 | logEvent{msg: "123456"}, 97 | logEvent{msg: "12345"}, 98 | logEvent{msg: "123"}, 99 | } 100 | assert.Equal(t, 92, events.size()) 101 | } 102 | 103 | // Assert that events are sorted by timestamp in ascending order 104 | func Test_eventList_Sort(t *testing.T) { 105 | sorted := eventsList{ 106 | logEvent{timestamp: 1}, 107 | logEvent{timestamp: 2}, 108 | } 109 | to_sort := eventsList{ 110 | logEvent{timestamp: 2}, 111 | logEvent{timestamp: 1}, 112 | } 113 | sort.Sort(to_sort) 114 | assert.Equal(t, sorted, to_sort) 115 | } 116 | -------------------------------------------------------------------------------- /receivers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net" 5 | "net/url" 6 | "strings" 7 | "sync" 8 | 9 | log "github.com/Sirupsen/logrus" 10 | ) 11 | 12 | type receiver interface { 13 | // Close connection and channels 14 | Close() 15 | // Run a goroutine and pass read messages to channel 16 | Receive() <-chan string 17 | // Listen for incoming packets 18 | Listen() error 19 | } 20 | 21 | type UDPreceiver struct { 22 | conn *net.UDPConn 23 | url *url.URL 24 | wg *sync.WaitGroup 25 | } 26 | 27 | func (rec *UDPreceiver) Close() { 28 | if rec.conn != nil { 29 | rec.conn.Close() 30 | rec.wg.Wait() 31 | } 32 | } 33 | 34 | func (rec *UDPreceiver) Listen() error { 35 | addr, err := net.ResolveUDPAddr("udp", rec.url.Host) 36 | if err != nil { 37 | return err 38 | } 39 | conn, err := net.ListenUDP("udp", addr) 40 | rec.conn = conn 41 | return err 42 | } 43 | 44 | func (rec *UDPreceiver) Receive() <-chan string { 45 | out := make(chan string, maxBatchEvents) 46 | rec.wg.Add(1) 47 | go func() { 48 | var buf [maxEventSize]byte 49 | defer rec.wg.Done() 50 | defer close(out) 51 | for { 52 | n, err := rec.conn.Read(buf[0:]) 53 | // For more info why string comparison see https://github.com/golang/go/issues/4373 54 | if err != nil && strings.Contains(err.Error(), "use of closed network connection") { 55 | return 56 | } else if err != nil { 57 | log.Fatal(err) 58 | } 59 | out <- string(buf[0:n]) 60 | } 61 | }() 62 | return out 63 | } 64 | 65 | // Create a new receiver based on passed address. 66 | func newReceiver(address string) receiver { 67 | url, _ := url.Parse(address) 68 | switch url.Scheme { 69 | case "udp": 70 | return &UDPreceiver{url: url, wg: &sync.WaitGroup{}} 71 | } 72 | return nil 73 | } 74 | -------------------------------------------------------------------------------- /release.go: -------------------------------------------------------------------------------- 1 | // +build !debug 2 | 3 | package main 4 | 5 | func debug() {} 6 | -------------------------------------------------------------------------------- /syslog.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "text/template" 6 | "time" 7 | ) 8 | 9 | type SyslogSeverity uint8 10 | type SyslogFacility uint8 11 | type SyslogPriority uint8 12 | 13 | type syslogMessage struct { 14 | Facility SyslogFacility 15 | Severity SyslogSeverity 16 | Message string 17 | Syslogtag string 18 | Hostname string 19 | timestamp time.Time 20 | } 21 | 22 | const maxMsgLen = 2048 23 | 24 | // From /usr/include/sys/syslog.h. 25 | const ( 26 | logEmerg SyslogSeverity = iota 27 | logAlert 28 | logCrit 29 | logErr 30 | logWarning 31 | logNotice 32 | logInfo 33 | logDebug 34 | ) 35 | 36 | var severityMap = map[SyslogSeverity]string{ 37 | logEmerg: "EMERG", 38 | logAlert: "ALERT", 39 | logCrit: "CRIT", 40 | logErr: "ERR", 41 | logWarning: "WARNING", 42 | logNotice: "NOTICE", 43 | logInfo: "INFO", 44 | logDebug: "DEBUG", 45 | } 46 | 47 | // From /usr/include/sys/syslog.h. 48 | const ( 49 | logKern SyslogFacility = iota 50 | logUser 51 | logMail 52 | logDaemon 53 | logAuth 54 | logSyslog 55 | logLpr 56 | logNews 57 | logUucp 58 | logClock 59 | logAuthpriv 60 | logFtp 61 | logNtp 62 | logLogaudit 63 | logLogalert 64 | logCron 65 | logLocal0 66 | logLocal1 67 | logLocal2 68 | logLocal3 69 | logLocal4 70 | logLocal5 71 | logLocal6 72 | logLocal7 73 | ) 74 | 75 | var facilityMap = map[SyslogFacility]string{ 76 | logKern: "KERN", 77 | logUser: "USER", 78 | logMail: "MAIL", 79 | logDaemon: "DAEMON", 80 | logAuth: "AUTH", 81 | logSyslog: "SYSLOG", 82 | logLpr: "LPR", 83 | logNews: "NEWS", 84 | logUucp: "UUCP", 85 | logClock: "CLOCK", 86 | logAuthpriv: "AUTHPRIV", 87 | logFtp: "FTP", 88 | logNtp: "NTP", 89 | logLogaudit: "LOGAUDIT", 90 | logLogalert: "LOGALERT", 91 | logCron: "CRON", 92 | logLocal0: "LOCAL0", 93 | logLocal1: "LOCAL1", 94 | logLocal2: "LOCAL2", 95 | logLocal3: "LOCAL3", 96 | logLocal4: "LOCAL4", 97 | logLocal5: "LOCAL5", 98 | logLocal6: "LOCAL6", 99 | logLocal7: "LOCAL7", 100 | } 101 | 102 | func (s SyslogSeverity) String() string { 103 | if val, ok := severityMap[s]; ok { 104 | return val 105 | } 106 | return "UNKNOWN" 107 | } 108 | 109 | func (f SyslogFacility) String() string { 110 | if val, ok := facilityMap[f]; ok { 111 | return val 112 | } 113 | return "UNKNOWN" 114 | } 115 | 116 | func (p SyslogPriority) decode() (SyslogFacility, SyslogSeverity) { 117 | return SyslogFacility(p / 8), SyslogSeverity(p % 8) 118 | } 119 | 120 | func (s syslogMessage) render(tpl *template.Template, buf *bytes.Buffer) error { 121 | buf.Reset() 122 | return tpl.Execute(buf, s) 123 | } 124 | -------------------------------------------------------------------------------- /syslog_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "testing" 7 | "text/template" 8 | 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | type TestSyslogPriority struct { 13 | priority SyslogPriority 14 | severity SyslogSeverity 15 | facility SyslogFacility 16 | } 17 | 18 | func TestSeverityStringUnknown(t *testing.T) { 19 | sev := SyslogSeverity(254) 20 | assert.Equal(t, "UNKNOWN", sev.String()) 21 | } 22 | 23 | func TestFacilityStringUnknown(t *testing.T) { 24 | fac := SyslogFacility(254) 25 | assert.Equal(t, "UNKNOWN", fac.String()) 26 | } 27 | 28 | func TestSeverityString(t *testing.T) { 29 | for sev, val := range severityMap { 30 | assert.Equal(t, val, sev.String()) 31 | } 32 | } 33 | 34 | func TestFacilityString(t *testing.T) { 35 | for fac, val := range facilityMap { 36 | assert.Equal(t, val, fac.String()) 37 | } 38 | } 39 | 40 | func TestDecodeSyslogPriority_severity(t *testing.T) { 41 | for _, elem := range testPriorities { 42 | _, severity := SyslogPriority.decode(elem.priority) 43 | assert.Equal(t, severity, elem.severity) 44 | } 45 | } 46 | 47 | func TestDecodeSyslogPriority_facility(t *testing.T) { 48 | for _, elem := range testPriorities { 49 | facility, _ := SyslogPriority.decode(elem.priority) 50 | assert.Equal(t, facility, elem.facility) 51 | } 52 | } 53 | 54 | // Assert that message is rendered with correct fields order 55 | func Test_syslogMessage_render_order(t *testing.T) { 56 | m := syslogMessage{ 57 | Syslogtag: "tag", 58 | Message: "message", 59 | } 60 | buf := bytes.NewBuffer([]byte{}) 61 | tpl, _ := template.New("").Parse("{{.Message}} {{.Syslogtag}}") 62 | m.render(tpl, buf) 63 | assert.Equal(t, "message tag", buf.String()) 64 | } 65 | 66 | // Assert that every exported field is rendered 67 | func Test_syslogMessage_render_field(t *testing.T) { 68 | m := syslogMessage{ 69 | Severity: logInfo, 70 | Facility: logAuthpriv, 71 | Hostname: "hostname", 72 | Syslogtag: "tag", 73 | Message: "message", 74 | } 75 | for field, expected := range map[string]string{ 76 | "Severity": m.Severity.String(), 77 | "Facility": m.Facility.String(), 78 | "Hostname": m.Hostname, 79 | "Syslogtag": m.Syslogtag, 80 | "Message": m.Message, 81 | } { 82 | buf := bytes.NewBuffer([]byte{}) 83 | tpl, _ := template.New("").Parse(fmt.Sprintf("{{.%s}}", field)) 84 | m.render(tpl, buf) 85 | assert.Equal(t, expected, buf.String()) 86 | } 87 | } 88 | 89 | func Test_syslogMessage_render_error(t *testing.T) { 90 | m := syslogMessage{} 91 | buf := bytes.NewBuffer([]byte{}) 92 | tpl, _ := template.New("").Parse("{{.UnexportedField}}") 93 | assert.NotNil(t, m.render(tpl, buf)) 94 | } 95 | 96 | // Assert that buffer is reset before rendering template 97 | func Test_syslogMessage_render_reset(t *testing.T) { 98 | m := syslogMessage{} 99 | buf := bytes.NewBuffer([]byte("should not be rendered")) 100 | tpl, _ := template.New("").Parse("") 101 | m.render(tpl, buf) 102 | assert.Equal(t, "", buf.String()) 103 | } 104 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.10.0 2 | 3 | * feature: Add a test hook (#180) 4 | * feature: `ParseLevel` is now case-insensitive (#326) 5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308) 6 | * performance: avoid re-allocations on `WithFields` (#335) 7 | 8 | # 0.9.0 9 | 10 | * logrus/text_formatter: don't emit empty msg 11 | * logrus/hooks/airbrake: move out of main repository 12 | * logrus/hooks/sentry: move out of main repository 13 | * logrus/hooks/papertrail: move out of main repository 14 | * logrus/hooks/bugsnag: move out of main repository 15 | * logrus/core: run tests with `-race` 16 | * logrus/core: detect TTY based on `stderr` 17 | * logrus/core: support `WithError` on logger 18 | * logrus/core: Solaris support 19 | 20 | # 0.8.7 21 | 22 | * logrus/core: fix possible race (#216) 23 | * logrus/doc: small typo fixes and doc improvements 24 | 25 | 26 | # 0.8.6 27 | 28 | * hooks/raven: allow passing an initialized client 29 | 30 | # 0.8.5 31 | 32 | * logrus/core: revert #208 33 | 34 | # 0.8.4 35 | 36 | * formatter/text: fix data race (#218) 37 | 38 | # 0.8.3 39 | 40 | * logrus/core: fix entry log level (#208) 41 | * logrus/core: improve performance of text formatter by 40% 42 | * logrus/core: expose `LevelHooks` type 43 | * logrus/core: add support for DragonflyBSD and NetBSD 44 | * formatter/text: print structs more verbosely 45 | 46 | # 0.8.2 47 | 48 | * logrus: fix more Fatal family functions 49 | 50 | # 0.8.1 51 | 52 | * logrus: fix not exiting on `Fatalf` and `Fatalln` 53 | 54 | # 0.8.0 55 | 56 | * logrus: defaults to stderr instead of stdout 57 | * hooks/sentry: add special field for `*http.Request` 58 | * formatter/text: ignore Windows for colors 59 | 60 | # 0.7.3 61 | 62 | * formatter/\*: allow configuration of timestamp layout 63 | 64 | # 0.7.2 65 | 66 | * formatter/text: Add configuration option for time format (#158) 67 | -------------------------------------------------------------------------------- /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/alt_exit.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // The following code was sourced and modified from the 4 | // https://bitbucket.org/tebeka/atexit package governed by the following license: 5 | // 6 | // Copyright (c) 2012 Miki Tebeka . 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | // this software and associated documentation files (the "Software"), to deal in 10 | // the Software without restriction, including without limitation the rights to 11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 | // the Software, and to permit persons to whom the Software is furnished to do so, 13 | // subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | import ( 26 | "fmt" 27 | "os" 28 | ) 29 | 30 | var handlers = []func(){} 31 | 32 | func runHandler(handler func()) { 33 | defer func() { 34 | if err := recover(); err != nil { 35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) 36 | } 37 | }() 38 | 39 | handler() 40 | } 41 | 42 | func runHandlers() { 43 | for _, handler := range handlers { 44 | runHandler(handler) 45 | } 46 | } 47 | 48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) 49 | func Exit(code int) { 50 | runHandlers() 51 | os.Exit(code) 52 | } 53 | 54 | // RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke 55 | // all handlers. The handlers will also be invoked when any Fatal log entry is 56 | // made. 57 | // 58 | // This method is useful when a caller wishes to use logrus to log a fatal 59 | // message but also needs to gracefully shutdown. An example usecase could be 60 | // closing database connections, or sending a alert that the application is 61 | // closing. 62 | func RegisterExitHandler(handler func()) { 63 | handlers = append(handlers, handler) 64 | } 65 | -------------------------------------------------------------------------------- /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/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/README.md: -------------------------------------------------------------------------------- 1 | # Syslog Hooks for Logrus :walrus: 2 | 3 | ## Usage 4 | 5 | ```go 6 | import ( 7 | "log/syslog" 8 | "github.com/Sirupsen/logrus" 9 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 10 | ) 11 | 12 | func main() { 13 | log := logrus.New() 14 | hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 15 | 16 | if err == nil { 17 | log.Hooks.Add(hook) 18 | } 19 | } 20 | ``` 21 | 22 | If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of `NewSyslogHook`. It should look like the following. 23 | 24 | ```go 25 | import ( 26 | "log/syslog" 27 | "github.com/Sirupsen/logrus" 28 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 29 | ) 30 | 31 | func main() { 32 | log := logrus.New() 33 | hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "") 34 | 35 | if err == nil { 36 | log.Hooks.Add(hook) 37 | } 38 | } 39 | ``` -------------------------------------------------------------------------------- /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/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | ) 8 | 9 | // Fields type, used to pass to `WithFields`. 10 | type Fields map[string]interface{} 11 | 12 | // Level type 13 | type Level uint8 14 | 15 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 16 | func (level Level) String() string { 17 | switch level { 18 | case DebugLevel: 19 | return "debug" 20 | case InfoLevel: 21 | return "info" 22 | case WarnLevel: 23 | return "warning" 24 | case ErrorLevel: 25 | return "error" 26 | case FatalLevel: 27 | return "fatal" 28 | case PanicLevel: 29 | return "panic" 30 | } 31 | 32 | return "unknown" 33 | } 34 | 35 | // ParseLevel takes a string level and returns the Logrus log level constant. 36 | func ParseLevel(lvl string) (Level, error) { 37 | switch strings.ToLower(lvl) { 38 | case "panic": 39 | return PanicLevel, nil 40 | case "fatal": 41 | return FatalLevel, nil 42 | case "error": 43 | return ErrorLevel, nil 44 | case "warn", "warning": 45 | return WarnLevel, nil 46 | case "info": 47 | return InfoLevel, nil 48 | case "debug": 49 | return DebugLevel, nil 50 | } 51 | 52 | var l Level 53 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 54 | } 55 | 56 | // A constant exposing all logging levels 57 | var AllLevels = []Level{ 58 | PanicLevel, 59 | FatalLevel, 60 | ErrorLevel, 61 | WarnLevel, 62 | InfoLevel, 63 | DebugLevel, 64 | } 65 | 66 | // These are the different logging levels. You can set the logging level to log 67 | // on your instance of logger, obtained with `logrus.New()`. 68 | const ( 69 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 70 | // message passed to Debug, Info, ... 71 | PanicLevel Level = iota 72 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 73 | // logging level is set to Panic. 74 | FatalLevel 75 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 76 | // Commonly used for hooks to send errors to an error tracking service. 77 | ErrorLevel 78 | // WarnLevel level. Non-critical entries that deserve eyes. 79 | WarnLevel 80 | // InfoLevel level. General operational entries about what's going on inside the 81 | // application. 82 | InfoLevel 83 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 84 | DebugLevel 85 | ) 86 | 87 | // Won't compile if StdLogger can't be realized by a log.Logger 88 | var ( 89 | _ StdLogger = &log.Logger{} 90 | _ StdLogger = &Entry{} 91 | _ StdLogger = &Logger{} 92 | ) 93 | 94 | // StdLogger is what your logrus-enabled library should take, that way 95 | // it'll accept a stdlib logger and a logrus logger. There's no standard 96 | // interface, this is the closest we get, unfortunately. 97 | type StdLogger interface { 98 | Print(...interface{}) 99 | Printf(string, ...interface{}) 100 | Println(...interface{}) 101 | 102 | Fatal(...interface{}) 103 | Fatalf(string, ...interface{}) 104 | Fatalln(...interface{}) 105 | 106 | Panic(...interface{}) 107 | Panicf(string, ...interface{}) 108 | Panicln(...interface{}) 109 | } 110 | 111 | // The FieldLogger interface generalizes the Entry and Logger types 112 | type FieldLogger interface { 113 | WithField(key string, value interface{}) *Entry 114 | WithFields(fields Fields) *Entry 115 | WithError(err error) *Entry 116 | 117 | Debugf(format string, args ...interface{}) 118 | Infof(format string, args ...interface{}) 119 | Printf(format string, args ...interface{}) 120 | Warnf(format string, args ...interface{}) 121 | Warningf(format string, args ...interface{}) 122 | Errorf(format string, args ...interface{}) 123 | Fatalf(format string, args ...interface{}) 124 | Panicf(format string, args ...interface{}) 125 | 126 | Debug(args ...interface{}) 127 | Info(args ...interface{}) 128 | Print(args ...interface{}) 129 | Warn(args ...interface{}) 130 | Warning(args ...interface{}) 131 | Error(args ...interface{}) 132 | Fatal(args ...interface{}) 133 | Panic(args ...interface{}) 134 | 135 | Debugln(args ...interface{}) 136 | Infoln(args ...interface{}) 137 | Println(args ...interface{}) 138 | Warnln(args ...interface{}) 139 | Warningln(args ...interface{}) 140 | Errorln(args ...interface{}) 141 | Fatalln(args ...interface{}) 142 | Panicln(args ...interface{}) 143 | } 144 | -------------------------------------------------------------------------------- /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/aws/aws-sdk-go/NOTICE.txt: -------------------------------------------------------------------------------- 1 | AWS SDK for Go 2 | Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Copyright 2014-2015 Stripe, Inc. 4 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "io" 5 | "reflect" 6 | "time" 7 | ) 8 | 9 | // Copy deeply copies a src structure to dst. Useful for copying request and 10 | // response structures. 11 | // 12 | // Can copy between structs of different type, but will only copy fields which 13 | // are assignable, and exist in both structs. Fields which are not assignable, 14 | // or do not exist in both structs are ignored. 15 | func Copy(dst, src interface{}) { 16 | dstval := reflect.ValueOf(dst) 17 | if !dstval.IsValid() { 18 | panic("Copy dst cannot be nil") 19 | } 20 | 21 | rcopy(dstval, reflect.ValueOf(src), true) 22 | } 23 | 24 | // CopyOf returns a copy of src while also allocating the memory for dst. 25 | // src must be a pointer type or this operation will fail. 26 | func CopyOf(src interface{}) (dst interface{}) { 27 | dsti := reflect.New(reflect.TypeOf(src).Elem()) 28 | dst = dsti.Interface() 29 | rcopy(dsti, reflect.ValueOf(src), true) 30 | return 31 | } 32 | 33 | // rcopy performs a recursive copy of values from the source to destination. 34 | // 35 | // root is used to skip certain aspects of the copy which are not valid 36 | // for the root node of a object. 37 | func rcopy(dst, src reflect.Value, root bool) { 38 | if !src.IsValid() { 39 | return 40 | } 41 | 42 | switch src.Kind() { 43 | case reflect.Ptr: 44 | if _, ok := src.Interface().(io.Reader); ok { 45 | if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() { 46 | dst.Elem().Set(src) 47 | } else if dst.CanSet() { 48 | dst.Set(src) 49 | } 50 | } else { 51 | e := src.Type().Elem() 52 | if dst.CanSet() && !src.IsNil() { 53 | if _, ok := src.Interface().(*time.Time); !ok { 54 | dst.Set(reflect.New(e)) 55 | } else { 56 | tempValue := reflect.New(e) 57 | tempValue.Elem().Set(src.Elem()) 58 | // Sets time.Time's unexported values 59 | dst.Set(tempValue) 60 | } 61 | } 62 | if src.Elem().IsValid() { 63 | // Keep the current root state since the depth hasn't changed 64 | rcopy(dst.Elem(), src.Elem(), root) 65 | } 66 | } 67 | case reflect.Struct: 68 | t := dst.Type() 69 | for i := 0; i < t.NumField(); i++ { 70 | name := t.Field(i).Name 71 | srcVal := src.FieldByName(name) 72 | dstVal := dst.FieldByName(name) 73 | if srcVal.IsValid() && dstVal.CanSet() { 74 | rcopy(dstVal, srcVal, false) 75 | } 76 | } 77 | case reflect.Slice: 78 | if src.IsNil() { 79 | break 80 | } 81 | 82 | s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap()) 83 | dst.Set(s) 84 | for i := 0; i < src.Len(); i++ { 85 | rcopy(dst.Index(i), src.Index(i), false) 86 | } 87 | case reflect.Map: 88 | if src.IsNil() { 89 | break 90 | } 91 | 92 | s := reflect.MakeMap(src.Type()) 93 | dst.Set(s) 94 | for _, k := range src.MapKeys() { 95 | v := src.MapIndex(k) 96 | v2 := reflect.New(v.Type()).Elem() 97 | rcopy(v2, v, false) 98 | dst.SetMapIndex(k, v2) 99 | } 100 | default: 101 | // Assign the value if possible. If its not assignable, the value would 102 | // need to be converted and the impact of that may be unexpected, or is 103 | // not compatible with the dst type. 104 | if src.Type().AssignableTo(dst.Type()) { 105 | dst.Set(src) 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "reflect" 5 | ) 6 | 7 | // DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. 8 | // In addition to this, this method will also dereference the input values if 9 | // possible so the DeepEqual performed will not fail if one parameter is a 10 | // pointer and the other is not. 11 | // 12 | // DeepEqual will not perform indirection of nested values of the input parameters. 13 | func DeepEqual(a, b interface{}) bool { 14 | ra := reflect.Indirect(reflect.ValueOf(a)) 15 | rb := reflect.Indirect(reflect.ValueOf(b)) 16 | 17 | if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid { 18 | // If the elements are both nil, and of the same type the are equal 19 | // If they are of different types they are not equal 20 | return reflect.TypeOf(a) == reflect.TypeOf(b) 21 | } else if raValid != rbValid { 22 | // Both values must be valid to be equal 23 | return false 24 | } 25 | 26 | return reflect.DeepEqual(ra.Interface(), rb.Interface()) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "reflect" 8 | "strings" 9 | ) 10 | 11 | // Prettify returns the string representation of a value. 12 | func Prettify(i interface{}) string { 13 | var buf bytes.Buffer 14 | prettify(reflect.ValueOf(i), 0, &buf) 15 | return buf.String() 16 | } 17 | 18 | // prettify will recursively walk value v to build a textual 19 | // representation of the value. 20 | func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { 21 | for v.Kind() == reflect.Ptr { 22 | v = v.Elem() 23 | } 24 | 25 | switch v.Kind() { 26 | case reflect.Struct: 27 | strtype := v.Type().String() 28 | if strtype == "time.Time" { 29 | fmt.Fprintf(buf, "%s", v.Interface()) 30 | break 31 | } else if strings.HasPrefix(strtype, "io.") { 32 | buf.WriteString("") 33 | break 34 | } 35 | 36 | buf.WriteString("{\n") 37 | 38 | names := []string{} 39 | for i := 0; i < v.Type().NumField(); i++ { 40 | name := v.Type().Field(i).Name 41 | f := v.Field(i) 42 | if name[0:1] == strings.ToLower(name[0:1]) { 43 | continue // ignore unexported fields 44 | } 45 | if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { 46 | continue // ignore unset fields 47 | } 48 | names = append(names, name) 49 | } 50 | 51 | for i, n := range names { 52 | val := v.FieldByName(n) 53 | buf.WriteString(strings.Repeat(" ", indent+2)) 54 | buf.WriteString(n + ": ") 55 | prettify(val, indent+2, buf) 56 | 57 | if i < len(names)-1 { 58 | buf.WriteString(",\n") 59 | } 60 | } 61 | 62 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 63 | case reflect.Slice: 64 | strtype := v.Type().String() 65 | if strtype == "[]uint8" { 66 | fmt.Fprintf(buf, " len %d", v.Len()) 67 | break 68 | } 69 | 70 | nl, id, id2 := "", "", "" 71 | if v.Len() > 3 { 72 | nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) 73 | } 74 | buf.WriteString("[" + nl) 75 | for i := 0; i < v.Len(); i++ { 76 | buf.WriteString(id2) 77 | prettify(v.Index(i), indent+2, buf) 78 | 79 | if i < v.Len()-1 { 80 | buf.WriteString("," + nl) 81 | } 82 | } 83 | 84 | buf.WriteString(nl + id + "]") 85 | case reflect.Map: 86 | buf.WriteString("{\n") 87 | 88 | for i, k := range v.MapKeys() { 89 | buf.WriteString(strings.Repeat(" ", indent+2)) 90 | buf.WriteString(k.String() + ": ") 91 | prettify(v.MapIndex(k), indent+2, buf) 92 | 93 | if i < v.Len()-1 { 94 | buf.WriteString(",\n") 95 | } 96 | } 97 | 98 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 99 | default: 100 | if !v.IsValid() { 101 | fmt.Fprint(buf, "") 102 | return 103 | } 104 | format := "%v" 105 | switch v.Interface().(type) { 106 | case string: 107 | format = "%q" 108 | case io.ReadSeeker, io.Reader: 109 | format = "buffer(%p)" 110 | } 111 | fmt.Fprintf(buf, format, v.Interface()) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "reflect" 7 | "strings" 8 | ) 9 | 10 | // StringValue returns the string representation of a value. 11 | func StringValue(i interface{}) string { 12 | var buf bytes.Buffer 13 | stringValue(reflect.ValueOf(i), 0, &buf) 14 | return buf.String() 15 | } 16 | 17 | func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) { 18 | for v.Kind() == reflect.Ptr { 19 | v = v.Elem() 20 | } 21 | 22 | switch v.Kind() { 23 | case reflect.Struct: 24 | buf.WriteString("{\n") 25 | 26 | names := []string{} 27 | for i := 0; i < v.Type().NumField(); i++ { 28 | name := v.Type().Field(i).Name 29 | f := v.Field(i) 30 | if name[0:1] == strings.ToLower(name[0:1]) { 31 | continue // ignore unexported fields 32 | } 33 | if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() { 34 | continue // ignore unset fields 35 | } 36 | names = append(names, name) 37 | } 38 | 39 | for i, n := range names { 40 | val := v.FieldByName(n) 41 | buf.WriteString(strings.Repeat(" ", indent+2)) 42 | buf.WriteString(n + ": ") 43 | stringValue(val, indent+2, buf) 44 | 45 | if i < len(names)-1 { 46 | buf.WriteString(",\n") 47 | } 48 | } 49 | 50 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 51 | case reflect.Slice: 52 | nl, id, id2 := "", "", "" 53 | if v.Len() > 3 { 54 | nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) 55 | } 56 | buf.WriteString("[" + nl) 57 | for i := 0; i < v.Len(); i++ { 58 | buf.WriteString(id2) 59 | stringValue(v.Index(i), indent+2, buf) 60 | 61 | if i < v.Len()-1 { 62 | buf.WriteString("," + nl) 63 | } 64 | } 65 | 66 | buf.WriteString(nl + id + "]") 67 | case reflect.Map: 68 | buf.WriteString("{\n") 69 | 70 | for i, k := range v.MapKeys() { 71 | buf.WriteString(strings.Repeat(" ", indent+2)) 72 | buf.WriteString(k.String() + ": ") 73 | stringValue(v.MapIndex(k), indent+2, buf) 74 | 75 | if i < v.Len()-1 { 76 | buf.WriteString(",\n") 77 | } 78 | } 79 | 80 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 81 | default: 82 | format := "%v" 83 | switch v.Interface().(type) { 84 | case string: 85 | format = "%q" 86 | } 87 | fmt.Fprintf(buf, format, v.Interface()) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "math/rand" 5 | "sync" 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | // DefaultRetryer implements basic retry logic using exponential backoff for 12 | // most services. If you want to implement custom retry logic, implement the 13 | // request.Retryer interface or create a structure type that composes this 14 | // struct and override the specific methods. For example, to override only 15 | // the MaxRetries method: 16 | // 17 | // type retryer struct { 18 | // service.DefaultRetryer 19 | // } 20 | // 21 | // // This implementation always has 100 max retries 22 | // func (d retryer) MaxRetries() uint { return 100 } 23 | type DefaultRetryer struct { 24 | NumMaxRetries int 25 | } 26 | 27 | // MaxRetries returns the number of maximum returns the service will use to make 28 | // an individual API request. 29 | func (d DefaultRetryer) MaxRetries() int { 30 | return d.NumMaxRetries 31 | } 32 | 33 | var seededRand = rand.New(&lockedSource{src: rand.NewSource(time.Now().UnixNano())}) 34 | 35 | // RetryRules returns the delay duration before retrying this request again 36 | func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration { 37 | // Set the upper limit of delay in retrying at ~five minutes 38 | minTime := 30 39 | throttle := d.shouldThrottle(r) 40 | if throttle { 41 | minTime = 500 42 | } 43 | 44 | retryCount := r.RetryCount 45 | if retryCount > 13 { 46 | retryCount = 13 47 | } else if throttle && retryCount > 8 { 48 | retryCount = 8 49 | } 50 | 51 | delay := (1 << uint(retryCount)) * (seededRand.Intn(minTime) + minTime) 52 | return time.Duration(delay) * time.Millisecond 53 | } 54 | 55 | // ShouldRetry returns true if the request should be retried. 56 | func (d DefaultRetryer) ShouldRetry(r *request.Request) bool { 57 | if r.HTTPResponse.StatusCode >= 500 { 58 | return true 59 | } 60 | return r.IsErrorRetryable() || d.shouldThrottle(r) 61 | } 62 | 63 | // ShouldThrottle returns true if the request should be throttled. 64 | func (d DefaultRetryer) shouldThrottle(r *request.Request) bool { 65 | if r.HTTPResponse.StatusCode == 502 || 66 | r.HTTPResponse.StatusCode == 503 || 67 | r.HTTPResponse.StatusCode == 504 { 68 | return true 69 | } 70 | return r.IsErrorThrottle() 71 | } 72 | 73 | // lockedSource is a thread-safe implementation of rand.Source 74 | type lockedSource struct { 75 | lk sync.Mutex 76 | src rand.Source 77 | } 78 | 79 | func (r *lockedSource) Int63() (n int64) { 80 | r.lk.Lock() 81 | n = r.src.Int63() 82 | r.lk.Unlock() 83 | return 84 | } 85 | 86 | func (r *lockedSource) Seed(seed int64) { 87 | r.lk.Lock() 88 | r.src.Seed(seed) 89 | r.lk.Unlock() 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | // ClientInfo wraps immutable data from the client.Client structure. 4 | type ClientInfo struct { 5 | ServiceName string 6 | APIVersion string 7 | Endpoint string 8 | SigningName string 9 | SigningRegion string 10 | JSONVersion string 11 | TargetPrefix string 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go: -------------------------------------------------------------------------------- 1 | package corehandlers 2 | 3 | import "github.com/aws/aws-sdk-go/aws/request" 4 | 5 | // ValidateParametersHandler is a request handler to validate the input parameters. 6 | // Validating parameters only has meaning if done prior to the request being sent. 7 | var ValidateParametersHandler = request.NamedHandler{Name: "core.ValidateParametersHandler", Fn: func(r *request.Request) { 8 | if !r.ParamsFilled() { 9 | return 10 | } 11 | 12 | if v, ok := r.Params.(request.Validator); ok { 13 | if err := v.Validate(); err != nil { 14 | r.Error = err 15 | } 16 | } 17 | }} 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/aws/awserr" 5 | ) 6 | 7 | var ( 8 | // ErrNoValidProvidersFoundInChain Is returned when there are no valid 9 | // providers in the ChainProvider. 10 | // 11 | // This has been deprecated. For verbose error messaging set 12 | // aws.Config.CredentialsChainVerboseErrors to true 13 | // 14 | // @readonly 15 | ErrNoValidProvidersFoundInChain = awserr.New("NoCredentialProviders", 16 | `no valid providers in chain. Deprecated. 17 | For verbose messaging see aws.Config.CredentialsChainVerboseErrors`, 18 | nil) 19 | ) 20 | 21 | // A ChainProvider will search for a provider which returns credentials 22 | // and cache that provider until Retrieve is called again. 23 | // 24 | // The ChainProvider provides a way of chaining multiple providers together 25 | // which will pick the first available using priority order of the Providers 26 | // in the list. 27 | // 28 | // If none of the Providers retrieve valid credentials Value, ChainProvider's 29 | // Retrieve() will return the error ErrNoValidProvidersFoundInChain. 30 | // 31 | // If a Provider is found which returns valid credentials Value ChainProvider 32 | // will cache that Provider for all calls to IsExpired(), until Retrieve is 33 | // called again. 34 | // 35 | // Example of ChainProvider to be used with an EnvProvider and EC2RoleProvider. 36 | // In this example EnvProvider will first check if any credentials are available 37 | // via the environment variables. If there are none ChainProvider will check 38 | // the next Provider in the list, EC2RoleProvider in this case. If EC2RoleProvider 39 | // does not return any credentials ChainProvider will return the error 40 | // ErrNoValidProvidersFoundInChain 41 | // 42 | // creds := NewChainCredentials( 43 | // []Provider{ 44 | // &EnvProvider{}, 45 | // &EC2RoleProvider{ 46 | // Client: ec2metadata.New(sess), 47 | // }, 48 | // }) 49 | // 50 | // // Usage of ChainCredentials with aws.Config 51 | // svc := ec2.New(&aws.Config{Credentials: creds}) 52 | // 53 | type ChainProvider struct { 54 | Providers []Provider 55 | curr Provider 56 | VerboseErrors bool 57 | } 58 | 59 | // NewChainCredentials returns a pointer to a new Credentials object 60 | // wrapping a chain of providers. 61 | func NewChainCredentials(providers []Provider) *Credentials { 62 | return NewCredentials(&ChainProvider{ 63 | Providers: append([]Provider{}, providers...), 64 | }) 65 | } 66 | 67 | // Retrieve returns the credentials value or error if no provider returned 68 | // without error. 69 | // 70 | // If a provider is found it will be cached and any calls to IsExpired() 71 | // will return the expired state of the cached provider. 72 | func (c *ChainProvider) Retrieve() (Value, error) { 73 | var errs []error 74 | for _, p := range c.Providers { 75 | creds, err := p.Retrieve() 76 | if err == nil { 77 | c.curr = p 78 | return creds, nil 79 | } 80 | errs = append(errs, err) 81 | } 82 | c.curr = nil 83 | 84 | var err error 85 | err = ErrNoValidProvidersFoundInChain 86 | if c.VerboseErrors { 87 | err = awserr.NewBatchError("NoCredentialProviders", "no valid providers in chain", errs) 88 | } 89 | return Value{}, err 90 | } 91 | 92 | // IsExpired will returned the expired state of the currently cached provider 93 | // if there is one. If there is no current provider, true will be returned. 94 | func (c *ChainProvider) IsExpired() bool { 95 | if c.curr != nil { 96 | return c.curr.IsExpired() 97 | } 98 | 99 | return true 100 | } 101 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/aws/aws-sdk-go/aws/awserr" 7 | ) 8 | 9 | // EnvProviderName provides a name of Env provider 10 | const EnvProviderName = "EnvProvider" 11 | 12 | var ( 13 | // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be 14 | // found in the process's environment. 15 | // 16 | // @readonly 17 | ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) 18 | 19 | // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key 20 | // can't be found in the process's environment. 21 | // 22 | // @readonly 23 | ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) 24 | ) 25 | 26 | // A EnvProvider retrieves credentials from the environment variables of the 27 | // running process. Environment credentials never expire. 28 | // 29 | // Environment variables used: 30 | // 31 | // * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY 32 | // * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY 33 | type EnvProvider struct { 34 | retrieved bool 35 | } 36 | 37 | // NewEnvCredentials returns a pointer to a new Credentials object 38 | // wrapping the environment variable provider. 39 | func NewEnvCredentials() *Credentials { 40 | return NewCredentials(&EnvProvider{}) 41 | } 42 | 43 | // Retrieve retrieves the keys from the environment. 44 | func (e *EnvProvider) Retrieve() (Value, error) { 45 | e.retrieved = false 46 | 47 | id := os.Getenv("AWS_ACCESS_KEY_ID") 48 | if id == "" { 49 | id = os.Getenv("AWS_ACCESS_KEY") 50 | } 51 | 52 | secret := os.Getenv("AWS_SECRET_ACCESS_KEY") 53 | if secret == "" { 54 | secret = os.Getenv("AWS_SECRET_KEY") 55 | } 56 | 57 | if id == "" { 58 | return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound 59 | } 60 | 61 | if secret == "" { 62 | return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound 63 | } 64 | 65 | e.retrieved = true 66 | return Value{ 67 | AccessKeyID: id, 68 | SecretAccessKey: secret, 69 | SessionToken: os.Getenv("AWS_SESSION_TOKEN"), 70 | ProviderName: EnvProviderName, 71 | }, nil 72 | } 73 | 74 | // IsExpired returns if the credentials have been retrieved. 75 | func (e *EnvProvider) IsExpired() bool { 76 | return !e.retrieved 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/example.ini: -------------------------------------------------------------------------------- 1 | [default] 2 | aws_access_key_id = accessKey 3 | aws_secret_access_key = secret 4 | aws_session_token = token 5 | 6 | [no_token] 7 | aws_access_key_id = accessKey 8 | aws_secret_access_key = secret 9 | 10 | [with_colon] 11 | aws_access_key_id: accessKey 12 | aws_secret_access_key: secret 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/aws/awserr" 5 | ) 6 | 7 | // StaticProviderName provides a name of Static provider 8 | const StaticProviderName = "StaticProvider" 9 | 10 | var ( 11 | // ErrStaticCredentialsEmpty is emitted when static credentials are empty. 12 | // 13 | // @readonly 14 | ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) 15 | ) 16 | 17 | // A StaticProvider is a set of credentials which are set programmatically, 18 | // and will never expire. 19 | type StaticProvider struct { 20 | Value 21 | } 22 | 23 | // NewStaticCredentials returns a pointer to a new Credentials object 24 | // wrapping a static credentials value provider. 25 | func NewStaticCredentials(id, secret, token string) *Credentials { 26 | return NewCredentials(&StaticProvider{Value: Value{ 27 | AccessKeyID: id, 28 | SecretAccessKey: secret, 29 | SessionToken: token, 30 | }}) 31 | } 32 | 33 | // NewStaticCredentialsFromCreds returns a pointer to a new Credentials object 34 | // wrapping the static credentials value provide. Same as NewStaticCredentials 35 | // but takes the creds Value instead of individual fields 36 | func NewStaticCredentialsFromCreds(creds Value) *Credentials { 37 | return NewCredentials(&StaticProvider{Value: creds}) 38 | } 39 | 40 | // Retrieve returns the credentials or error if the credentials are invalid. 41 | func (s *StaticProvider) Retrieve() (Value, error) { 42 | if s.AccessKeyID == "" || s.SecretAccessKey == "" { 43 | return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty 44 | } 45 | 46 | if len(s.Value.ProviderName) == 0 { 47 | s.Value.ProviderName = StaticProviderName 48 | } 49 | return s.Value, nil 50 | } 51 | 52 | // IsExpired returns if the credentials are expired. 53 | // 54 | // For StaticProvider, the credentials never expired. 55 | func (s *StaticProvider) IsExpired() bool { 56 | return false 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go: -------------------------------------------------------------------------------- 1 | // Package ec2metadata provides the client for making API calls to the 2 | // EC2 Metadata service. 3 | package ec2metadata 4 | 5 | import ( 6 | "bytes" 7 | "errors" 8 | "io" 9 | "net/http" 10 | "time" 11 | 12 | "github.com/aws/aws-sdk-go/aws" 13 | "github.com/aws/aws-sdk-go/aws/awserr" 14 | "github.com/aws/aws-sdk-go/aws/client" 15 | "github.com/aws/aws-sdk-go/aws/client/metadata" 16 | "github.com/aws/aws-sdk-go/aws/request" 17 | ) 18 | 19 | // ServiceName is the name of the service. 20 | const ServiceName = "ec2metadata" 21 | 22 | // A EC2Metadata is an EC2 Metadata service Client. 23 | type EC2Metadata struct { 24 | *client.Client 25 | } 26 | 27 | // New creates a new instance of the EC2Metadata client with a session. 28 | // This client is safe to use across multiple goroutines. 29 | // 30 | // 31 | // Example: 32 | // // Create a EC2Metadata client from just a session. 33 | // svc := ec2metadata.New(mySession) 34 | // 35 | // // Create a EC2Metadata client with additional configuration 36 | // svc := ec2metadata.New(mySession, aws.NewConfig().WithLogLevel(aws.LogDebugHTTPBody)) 37 | func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2Metadata { 38 | c := p.ClientConfig(ServiceName, cfgs...) 39 | return NewClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion) 40 | } 41 | 42 | // NewClient returns a new EC2Metadata client. Should be used to create 43 | // a client when not using a session. Generally using just New with a session 44 | // is preferred. 45 | // 46 | // If an unmodified HTTP client is provided from the stdlib default, or no client 47 | // the EC2RoleProvider's EC2Metadata HTTP client's timeout will be shortened. 48 | // To disable this set Config.EC2MetadataDisableTimeoutOverride to false. Enabled by default. 49 | func NewClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string, opts ...func(*client.Client)) *EC2Metadata { 50 | if !aws.BoolValue(cfg.EC2MetadataDisableTimeoutOverride) && httpClientZero(cfg.HTTPClient) { 51 | // If the http client is unmodified and this feature is not disabled 52 | // set custom timeouts for EC2Metadata requests. 53 | cfg.HTTPClient = &http.Client{ 54 | // use a shorter timeout than default because the metadata 55 | // service is local if it is running, and to fail faster 56 | // if not running on an ec2 instance. 57 | Timeout: 5 * time.Second, 58 | } 59 | } 60 | 61 | svc := &EC2Metadata{ 62 | Client: client.New( 63 | cfg, 64 | metadata.ClientInfo{ 65 | ServiceName: ServiceName, 66 | Endpoint: endpoint, 67 | APIVersion: "latest", 68 | }, 69 | handlers, 70 | ), 71 | } 72 | 73 | svc.Handlers.Unmarshal.PushBack(unmarshalHandler) 74 | svc.Handlers.UnmarshalError.PushBack(unmarshalError) 75 | svc.Handlers.Validate.Clear() 76 | svc.Handlers.Validate.PushBack(validateEndpointHandler) 77 | 78 | // Add additional options to the service config 79 | for _, option := range opts { 80 | option(svc.Client) 81 | } 82 | 83 | return svc 84 | } 85 | 86 | func httpClientZero(c *http.Client) bool { 87 | return c == nil || (c.Transport == nil && c.CheckRedirect == nil && c.Jar == nil && c.Timeout == 0) 88 | } 89 | 90 | type metadataOutput struct { 91 | Content string 92 | } 93 | 94 | func unmarshalHandler(r *request.Request) { 95 | defer r.HTTPResponse.Body.Close() 96 | b := &bytes.Buffer{} 97 | if _, err := io.Copy(b, r.HTTPResponse.Body); err != nil { 98 | r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata respose", err) 99 | return 100 | } 101 | 102 | if data, ok := r.Data.(*metadataOutput); ok { 103 | data.Content = b.String() 104 | } 105 | } 106 | 107 | func unmarshalError(r *request.Request) { 108 | defer r.HTTPResponse.Body.Close() 109 | b := &bytes.Buffer{} 110 | if _, err := io.Copy(b, r.HTTPResponse.Body); err != nil { 111 | r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata error respose", err) 112 | return 113 | } 114 | 115 | // Response body format is not consistent between metadata endpoints. 116 | // Grab the error message as a string and include that as the source error 117 | r.Error = awserr.New("EC2MetadataError", "failed to make EC2Metadata request", errors.New(b.String())) 118 | } 119 | 120 | func validateEndpointHandler(r *request.Request) { 121 | if r.ClientInfo.Endpoint == "" { 122 | r.Error = aws.ErrMissingEndpoint 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/endpoints/decode.go: -------------------------------------------------------------------------------- 1 | package endpoints 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | ) 10 | 11 | type modelDefinition map[string]json.RawMessage 12 | 13 | // A DecodeModelOptions are the options for how the endpoints model definition 14 | // are decoded. 15 | type DecodeModelOptions struct { 16 | SkipCustomizations bool 17 | } 18 | 19 | // Set combines all of the option functions together. 20 | func (d *DecodeModelOptions) Set(optFns ...func(*DecodeModelOptions)) { 21 | for _, fn := range optFns { 22 | fn(d) 23 | } 24 | } 25 | 26 | // DecodeModel unmarshals a Regions and Endpoint model definition file into 27 | // a endpoint Resolver. If the file format is not supported, or an error occurs 28 | // when unmarshaling the model an error will be returned. 29 | // 30 | // Casting the return value of this func to a EnumPartitions will 31 | // allow you to get a list of the partitions in the order the endpoints 32 | // will be resolved in. 33 | // 34 | // resolver, err := endpoints.DecodeModel(reader) 35 | // 36 | // partitions := resolver.(endpoints.EnumPartitions).Partitions() 37 | // for _, p := range partitions { 38 | // // ... inspect partitions 39 | // } 40 | func DecodeModel(r io.Reader, optFns ...func(*DecodeModelOptions)) (Resolver, error) { 41 | var opts DecodeModelOptions 42 | opts.Set(optFns...) 43 | 44 | // Get the version of the partition file to determine what 45 | // unmarshaling model to use. 46 | modelDef := modelDefinition{} 47 | if err := json.NewDecoder(r).Decode(&modelDef); err != nil { 48 | return nil, newDecodeModelError("failed to decode endpoints model", err) 49 | } 50 | 51 | var version string 52 | if b, ok := modelDef["version"]; ok { 53 | version = string(b) 54 | } else { 55 | return nil, newDecodeModelError("endpoints version not found in model", nil) 56 | } 57 | 58 | if version == "3" { 59 | return decodeV3Endpoints(modelDef, opts) 60 | } 61 | 62 | return nil, newDecodeModelError( 63 | fmt.Sprintf("endpoints version %s, not supported", version), nil) 64 | } 65 | 66 | func decodeV3Endpoints(modelDef modelDefinition, opts DecodeModelOptions) (Resolver, error) { 67 | b, ok := modelDef["partitions"] 68 | if !ok { 69 | return nil, newDecodeModelError("endpoints model missing partitions", nil) 70 | } 71 | 72 | ps := partitions{} 73 | if err := json.Unmarshal(b, &ps); err != nil { 74 | return nil, newDecodeModelError("failed to decode endpoints model", err) 75 | } 76 | 77 | if opts.SkipCustomizations { 78 | return ps, nil 79 | } 80 | 81 | // Customization 82 | for i := 0; i < len(ps); i++ { 83 | p := &ps[i] 84 | custAddEC2Metadata(p) 85 | custAddS3DualStack(p) 86 | custRmIotDataService(p) 87 | } 88 | 89 | return ps, nil 90 | } 91 | 92 | func custAddS3DualStack(p *partition) { 93 | if p.ID != "aws" { 94 | return 95 | } 96 | 97 | s, ok := p.Services["s3"] 98 | if !ok { 99 | return 100 | } 101 | 102 | s.Defaults.HasDualStack = boxedTrue 103 | s.Defaults.DualStackHostname = "{service}.dualstack.{region}.{dnsSuffix}" 104 | 105 | p.Services["s3"] = s 106 | } 107 | 108 | func custAddEC2Metadata(p *partition) { 109 | p.Services["ec2metadata"] = service{ 110 | IsRegionalized: boxedFalse, 111 | PartitionEndpoint: "aws-global", 112 | Endpoints: endpoints{ 113 | "aws-global": endpoint{ 114 | Hostname: "169.254.169.254/latest", 115 | Protocols: []string{"http"}, 116 | }, 117 | }, 118 | } 119 | } 120 | 121 | func custRmIotDataService(p *partition) { 122 | delete(p.Services, "data.iot") 123 | } 124 | 125 | type decodeModelError struct { 126 | awsError 127 | } 128 | 129 | func newDecodeModelError(msg string, err error) decodeModelError { 130 | return decodeModelError{ 131 | awsError: awserr.New("DecodeEndpointsModelError", msg, err), 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/endpoints/doc.go: -------------------------------------------------------------------------------- 1 | // Package endpoints provides the types and functionality for defining regions 2 | // and endpoints, as well as querying those definitions. 3 | // 4 | // The SDK's Regions and Endpoints metadata is code generated into the endpoints 5 | // package, and is accessible via the DefaultResolver function. This function 6 | // returns a endpoint Resolver will search the metadata and build an associated 7 | // endpoint if one is found. The default resolver will search all partitions 8 | // known by the SDK. e.g AWS Standard (aws), AWS China (aws-cn), and 9 | // AWS GovCloud (US) (aws-us-gov). 10 | // . 11 | // 12 | // Enumerating Regions and Endpoint Metadata 13 | // 14 | // Casting the Resolver returned by DefaultResolver to a EnumPartitions interface 15 | // will allow you to get access to the list of underlying Partitions with the 16 | // Partitions method. This is helpful if you want to limit the SDK's endpoint 17 | // resolving to a single partition, or enumerate regions, services, and endpoints 18 | // in the partition. 19 | // 20 | // resolver := endpoints.DefaultResolver() 21 | // partitions := resolver.(endpoints.EnumPartitions).Partitions() 22 | // 23 | // for _, p := range partitions { 24 | // fmt.Println("Regions for", p.Name) 25 | // for id, _ := range p.Regions() { 26 | // fmt.Println("*", id) 27 | // } 28 | // 29 | // fmt.Println("Services for", p.Name) 30 | // for id, _ := range p.Services() { 31 | // fmt.Println("*", id) 32 | // } 33 | // } 34 | // 35 | // Using Custom Endpoints 36 | // 37 | // The endpoints package also gives you the ability to use your own logic how 38 | // endpoints are resolved. This is a great way to define a custom endpoint 39 | // for select services, without passing that logic down through your code. 40 | // 41 | // If a type implements the Resolver interface it can be used to resolve 42 | // endpoints. To use this with the SDK's Session and Config set the value 43 | // of the type to the EndpointsResolver field of aws.Config when initializing 44 | // the session, or service client. 45 | // 46 | // In addition the ResolverFunc is a wrapper for a func matching the signature 47 | // of Resolver.EndpointFor, converting it to a type that satisfies the 48 | // Resolver interface. 49 | // 50 | // 51 | // myCustomResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) { 52 | // if service == endpoints.S3ServiceID { 53 | // return endpoints.ResolvedEndpoint{ 54 | // URL: "s3.custom.endpoint.com", 55 | // SigningRegion: "custom-signing-region", 56 | // }, nil 57 | // } 58 | // 59 | // return endpoints.DefaultResolver().EndpointFor(service, region, optFns...) 60 | // } 61 | // 62 | // sess := session.Must(session.NewSession(&aws.Config{ 63 | // Region: aws.String("us-west-2"), 64 | // EndpointResolver: endpoints.ResolverFunc(myCustomResolver), 65 | // })) 66 | package endpoints 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/errors.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import "github.com/aws/aws-sdk-go/aws/awserr" 4 | 5 | var ( 6 | // ErrMissingRegion is an error that is returned if region configuration is 7 | // not found. 8 | // 9 | // @readonly 10 | ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) 11 | 12 | // ErrMissingEndpoint is an error that is returned if an endpoint cannot be 13 | // resolved for a service. 14 | // 15 | // @readonly 16 | ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/logger.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | // A LogLevelType defines the level logging should be performed at. Used to instruct 9 | // the SDK which statements should be logged. 10 | type LogLevelType uint 11 | 12 | // LogLevel returns the pointer to a LogLevel. Should be used to workaround 13 | // not being able to take the address of a non-composite literal. 14 | func LogLevel(l LogLevelType) *LogLevelType { 15 | return &l 16 | } 17 | 18 | // Value returns the LogLevel value or the default value LogOff if the LogLevel 19 | // is nil. Safe to use on nil value LogLevelTypes. 20 | func (l *LogLevelType) Value() LogLevelType { 21 | if l != nil { 22 | return *l 23 | } 24 | return LogOff 25 | } 26 | 27 | // Matches returns true if the v LogLevel is enabled by this LogLevel. Should be 28 | // used with logging sub levels. Is safe to use on nil value LogLevelTypes. If 29 | // LogLevel is nill, will default to LogOff comparison. 30 | func (l *LogLevelType) Matches(v LogLevelType) bool { 31 | c := l.Value() 32 | return c&v == v 33 | } 34 | 35 | // AtLeast returns true if this LogLevel is at least high enough to satisfies v. 36 | // Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default 37 | // to LogOff comparison. 38 | func (l *LogLevelType) AtLeast(v LogLevelType) bool { 39 | c := l.Value() 40 | return c >= v 41 | } 42 | 43 | const ( 44 | // LogOff states that no logging should be performed by the SDK. This is the 45 | // default state of the SDK, and should be use to disable all logging. 46 | LogOff LogLevelType = iota * 0x1000 47 | 48 | // LogDebug state that debug output should be logged by the SDK. This should 49 | // be used to inspect request made and responses received. 50 | LogDebug 51 | ) 52 | 53 | // Debug Logging Sub Levels 54 | const ( 55 | // LogDebugWithSigning states that the SDK should log request signing and 56 | // presigning events. This should be used to log the signing details of 57 | // requests for debugging. Will also enable LogDebug. 58 | LogDebugWithSigning LogLevelType = LogDebug | (1 << iota) 59 | 60 | // LogDebugWithHTTPBody states the SDK should log HTTP request and response 61 | // HTTP bodys in addition to the headers and path. This should be used to 62 | // see the body content of requests and responses made while using the SDK 63 | // Will also enable LogDebug. 64 | LogDebugWithHTTPBody 65 | 66 | // LogDebugWithRequestRetries states the SDK should log when service requests will 67 | // be retried. This should be used to log when you want to log when service 68 | // requests are being retried. Will also enable LogDebug. 69 | LogDebugWithRequestRetries 70 | 71 | // LogDebugWithRequestErrors states the SDK should log when service requests fail 72 | // to build, send, validate, or unmarshal. 73 | LogDebugWithRequestErrors 74 | ) 75 | 76 | // A Logger is a minimalistic interface for the SDK to log messages to. Should 77 | // be used to provide custom logging writers for the SDK to use. 78 | type Logger interface { 79 | Log(...interface{}) 80 | } 81 | 82 | // A LoggerFunc is a convenience type to convert a function taking a variadic 83 | // list of arguments and wrap it so the Logger interface can be used. 84 | // 85 | // Example: 86 | // s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { 87 | // fmt.Fprintln(os.Stdout, args...) 88 | // })}) 89 | type LoggerFunc func(...interface{}) 90 | 91 | // Log calls the wrapped function with the arguments provided 92 | func (f LoggerFunc) Log(args ...interface{}) { 93 | f(args...) 94 | } 95 | 96 | // NewDefaultLogger returns a Logger which will write log messages to stdout, and 97 | // use same formatting runes as the stdlib log.Logger 98 | func NewDefaultLogger() Logger { 99 | return &defaultLogger{ 100 | logger: log.New(os.Stdout, "", log.LstdFlags), 101 | } 102 | } 103 | 104 | // A defaultLogger provides a minimalistic logger satisfying the Logger interface. 105 | type defaultLogger struct { 106 | logger *log.Logger 107 | } 108 | 109 | // Log logs the parameters to the stdlib logger. See log.Println. 110 | func (l defaultLogger) Log(args ...interface{}) { 111 | l.logger.Println(args...) 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/http_request.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/url" 7 | ) 8 | 9 | func copyHTTPRequest(r *http.Request, body io.ReadCloser) *http.Request { 10 | req := new(http.Request) 11 | *req = *r 12 | req.URL = &url.URL{} 13 | *req.URL = *r.URL 14 | req.Body = body 15 | 16 | req.Header = http.Header{} 17 | for k, v := range r.Header { 18 | for _, vv := range v { 19 | req.Header.Add(k, vv) 20 | } 21 | } 22 | 23 | return req 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | ) 7 | 8 | // offsetReader is a thread-safe io.ReadCloser to prevent racing 9 | // with retrying requests 10 | type offsetReader struct { 11 | buf io.ReadSeeker 12 | lock sync.Mutex 13 | closed bool 14 | } 15 | 16 | func newOffsetReader(buf io.ReadSeeker, offset int64) *offsetReader { 17 | reader := &offsetReader{} 18 | buf.Seek(offset, 0) 19 | 20 | reader.buf = buf 21 | return reader 22 | } 23 | 24 | // Close will close the instance of the offset reader's access to 25 | // the underlying io.ReadSeeker. 26 | func (o *offsetReader) Close() error { 27 | o.lock.Lock() 28 | defer o.lock.Unlock() 29 | o.closed = true 30 | return nil 31 | } 32 | 33 | // Read is a thread-safe read of the underlying io.ReadSeeker 34 | func (o *offsetReader) Read(p []byte) (int, error) { 35 | o.lock.Lock() 36 | defer o.lock.Unlock() 37 | 38 | if o.closed { 39 | return 0, io.EOF 40 | } 41 | 42 | return o.buf.Read(p) 43 | } 44 | 45 | // Seek is a thread-safe seeking operation. 46 | func (o *offsetReader) Seek(offset int64, whence int) (int64, error) { 47 | o.lock.Lock() 48 | defer o.lock.Unlock() 49 | 50 | return o.buf.Seek(offset, whence) 51 | } 52 | 53 | // CloseAndCopy will return a new offsetReader with a copy of the old buffer 54 | // and close the old buffer. 55 | func (o *offsetReader) CloseAndCopy(offset int64) *offsetReader { 56 | o.Close() 57 | return newOffsetReader(o.buf, offset) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_7.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package request 4 | 5 | import "io" 6 | 7 | // NoBody is an io.ReadCloser with no bytes. Read always returns EOF 8 | // and Close always returns nil. It can be used in an outgoing client 9 | // request to explicitly signal that a request has zero bytes. 10 | // An alternative, however, is to simply set Request.Body to nil. 11 | // 12 | // Copy of Go 1.8 NoBody type from net/http/http.go 13 | type noBody struct{} 14 | 15 | func (noBody) Read([]byte) (int, error) { return 0, io.EOF } 16 | func (noBody) Close() error { return nil } 17 | func (noBody) WriteTo(io.Writer) (int64, error) { return 0, nil } 18 | 19 | // Is an empty reader that will trigger the Go HTTP client to not include 20 | // and body in the HTTP request. 21 | var noBodyReader = noBody{} 22 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package request 4 | 5 | import "net/http" 6 | 7 | // Is a http.NoBody reader instructing Go HTTP client to not include 8 | // and body in the HTTP request. 9 | var noBodyReader = http.NoBody 10 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/awsutil" 8 | ) 9 | 10 | //type Paginater interface { 11 | // HasNextPage() bool 12 | // NextPage() *Request 13 | // EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error 14 | //} 15 | 16 | // HasNextPage returns true if this request has more pages of data available. 17 | func (r *Request) HasNextPage() bool { 18 | return len(r.nextPageTokens()) > 0 19 | } 20 | 21 | // nextPageTokens returns the tokens to use when asking for the next page of 22 | // data. 23 | func (r *Request) nextPageTokens() []interface{} { 24 | if r.Operation.Paginator == nil { 25 | return nil 26 | } 27 | 28 | if r.Operation.TruncationToken != "" { 29 | tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken) 30 | if len(tr) == 0 { 31 | return nil 32 | } 33 | 34 | switch v := tr[0].(type) { 35 | case *bool: 36 | if !aws.BoolValue(v) { 37 | return nil 38 | } 39 | case bool: 40 | if v == false { 41 | return nil 42 | } 43 | } 44 | } 45 | 46 | tokens := []interface{}{} 47 | tokenAdded := false 48 | for _, outToken := range r.Operation.OutputTokens { 49 | v, _ := awsutil.ValuesAtPath(r.Data, outToken) 50 | if len(v) > 0 { 51 | tokens = append(tokens, v[0]) 52 | tokenAdded = true 53 | } else { 54 | tokens = append(tokens, nil) 55 | } 56 | } 57 | if !tokenAdded { 58 | return nil 59 | } 60 | 61 | return tokens 62 | } 63 | 64 | // NextPage returns a new Request that can be executed to return the next 65 | // page of result data. Call .Send() on this request to execute it. 66 | func (r *Request) NextPage() *Request { 67 | tokens := r.nextPageTokens() 68 | if len(tokens) == 0 { 69 | return nil 70 | } 71 | 72 | data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface() 73 | nr := New(r.Config, r.ClientInfo, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data) 74 | for i, intok := range nr.Operation.InputTokens { 75 | awsutil.SetValueAtPath(nr.Params, intok, tokens[i]) 76 | } 77 | return nr 78 | } 79 | 80 | // EachPage iterates over each page of a paginated request object. The fn 81 | // parameter should be a function with the following sample signature: 82 | // 83 | // func(page *T, lastPage bool) bool { 84 | // return true // return false to stop iterating 85 | // } 86 | // 87 | // Where "T" is the structure type matching the output structure of the given 88 | // operation. For example, a request object generated by 89 | // DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput 90 | // as the structure "T". The lastPage value represents whether the page is 91 | // the last page of data or not. The return value of this function should 92 | // return true to keep iterating or false to stop. 93 | func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error { 94 | for page := r; page != nil; page = page.NextPage() { 95 | if err := page.Send(); err != nil { 96 | return err 97 | } 98 | if getNextPage := fn(page.Data, !page.HasNextPage()); !getNextPage { 99 | return page.Error 100 | } 101 | } 102 | 103 | return nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | ) 9 | 10 | // Retryer is an interface to control retry logic for a given service. 11 | // The default implementation used by most services is the service.DefaultRetryer 12 | // structure, which contains basic retry logic using exponential backoff. 13 | type Retryer interface { 14 | RetryRules(*Request) time.Duration 15 | ShouldRetry(*Request) bool 16 | MaxRetries() int 17 | } 18 | 19 | // WithRetryer sets a config Retryer value to the given Config returning it 20 | // for chaining. 21 | func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { 22 | cfg.Retryer = retryer 23 | return cfg 24 | } 25 | 26 | // retryableCodes is a collection of service response codes which are retry-able 27 | // without any further action. 28 | var retryableCodes = map[string]struct{}{ 29 | "RequestError": {}, 30 | "RequestTimeout": {}, 31 | } 32 | 33 | var throttleCodes = map[string]struct{}{ 34 | "ProvisionedThroughputExceededException": {}, 35 | "Throttling": {}, 36 | "ThrottlingException": {}, 37 | "RequestLimitExceeded": {}, 38 | "RequestThrottled": {}, 39 | "LimitExceededException": {}, // Deleting 10+ DynamoDb tables at once 40 | "TooManyRequestsException": {}, // Lambda functions 41 | "PriorRequestNotComplete": {}, // Route53 42 | } 43 | 44 | // credsExpiredCodes is a collection of error codes which signify the credentials 45 | // need to be refreshed. Expired tokens require refreshing of credentials, and 46 | // resigning before the request can be retried. 47 | var credsExpiredCodes = map[string]struct{}{ 48 | "ExpiredToken": {}, 49 | "ExpiredTokenException": {}, 50 | "RequestExpired": {}, // EC2 Only 51 | } 52 | 53 | func isCodeThrottle(code string) bool { 54 | _, ok := throttleCodes[code] 55 | return ok 56 | } 57 | 58 | func isCodeRetryable(code string) bool { 59 | if _, ok := retryableCodes[code]; ok { 60 | return true 61 | } 62 | 63 | return isCodeExpiredCreds(code) 64 | } 65 | 66 | func isCodeExpiredCreds(code string) bool { 67 | _, ok := credsExpiredCodes[code] 68 | return ok 69 | } 70 | 71 | // IsErrorRetryable returns whether the error is retryable, based on its Code. 72 | // Returns false if the request has no Error set. 73 | func (r *Request) IsErrorRetryable() bool { 74 | if r.Error != nil { 75 | if err, ok := r.Error.(awserr.Error); ok { 76 | return isCodeRetryable(err.Code()) 77 | } 78 | } 79 | return false 80 | } 81 | 82 | // IsErrorThrottle returns whether the error is to be throttled based on its code. 83 | // Returns false if the request has no Error set 84 | func (r *Request) IsErrorThrottle() bool { 85 | if r.Error != nil { 86 | if err, ok := r.Error.(awserr.Error); ok { 87 | return isCodeThrottle(err.Code()) 88 | } 89 | } 90 | return false 91 | } 92 | 93 | // IsErrorExpired returns whether the error code is a credential expiry error. 94 | // Returns false if the request has no Error set. 95 | func (r *Request) IsErrorExpired() bool { 96 | if r.Error != nil { 97 | if err, ok := r.Error.(awserr.Error); ok { 98 | return isCodeExpiredCreds(err.Code()) 99 | } 100 | } 101 | return false 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go: -------------------------------------------------------------------------------- 1 | package v4 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | ) 7 | 8 | // validator houses a set of rule needed for validation of a 9 | // string value 10 | type rules []rule 11 | 12 | // rule interface allows for more flexible rules and just simply 13 | // checks whether or not a value adheres to that rule 14 | type rule interface { 15 | IsValid(value string) bool 16 | } 17 | 18 | // IsValid will iterate through all rules and see if any rules 19 | // apply to the value and supports nested rules 20 | func (r rules) IsValid(value string) bool { 21 | for _, rule := range r { 22 | if rule.IsValid(value) { 23 | return true 24 | } 25 | } 26 | return false 27 | } 28 | 29 | // mapRule generic rule for maps 30 | type mapRule map[string]struct{} 31 | 32 | // IsValid for the map rule satisfies whether it exists in the map 33 | func (m mapRule) IsValid(value string) bool { 34 | _, ok := m[value] 35 | return ok 36 | } 37 | 38 | // whitelist is a generic rule for whitelisting 39 | type whitelist struct { 40 | rule 41 | } 42 | 43 | // IsValid for whitelist checks if the value is within the whitelist 44 | func (w whitelist) IsValid(value string) bool { 45 | return w.rule.IsValid(value) 46 | } 47 | 48 | // blacklist is a generic rule for blacklisting 49 | type blacklist struct { 50 | rule 51 | } 52 | 53 | // IsValid for whitelist checks if the value is within the whitelist 54 | func (b blacklist) IsValid(value string) bool { 55 | return !b.rule.IsValid(value) 56 | } 57 | 58 | type patterns []string 59 | 60 | // IsValid for patterns checks each pattern and returns if a match has 61 | // been found 62 | func (p patterns) IsValid(value string) bool { 63 | for _, pattern := range p { 64 | if strings.HasPrefix(http.CanonicalHeaderKey(value), pattern) { 65 | return true 66 | } 67 | } 68 | return false 69 | } 70 | 71 | // inclusiveRules rules allow for rules to depend on one another 72 | type inclusiveRules []rule 73 | 74 | // IsValid will return true if all rules are true 75 | func (r inclusiveRules) IsValid(value string) bool { 76 | for _, rule := range r { 77 | if !rule.IsValid(value) { 78 | return false 79 | } 80 | } 81 | return true 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/uri_path.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package v4 4 | 5 | import ( 6 | "net/url" 7 | "strings" 8 | ) 9 | 10 | func getURIPath(u *url.URL) string { 11 | var uri string 12 | 13 | if len(u.Opaque) > 0 { 14 | uri = "/" + strings.Join(strings.Split(u.Opaque, "/")[3:], "/") 15 | } else { 16 | uri = u.EscapedPath() 17 | } 18 | 19 | if len(uri) == 0 { 20 | uri = "/" 21 | } 22 | 23 | return uri 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/types.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | ) 7 | 8 | // ReadSeekCloser wraps a io.Reader returning a ReaderSeekerCloser. Should 9 | // only be used with an io.Reader that is also an io.Seeker. Doing so may 10 | // cause request signature errors, or request body's not sent for GET, HEAD 11 | // and DELETE HTTP methods. 12 | // 13 | // Deprecated: Should only be used with io.ReadSeeker. If using for 14 | // S3 PutObject to stream content use s3manager.Uploader instead. 15 | func ReadSeekCloser(r io.Reader) ReaderSeekerCloser { 16 | return ReaderSeekerCloser{r} 17 | } 18 | 19 | // ReaderSeekerCloser represents a reader that can also delegate io.Seeker and 20 | // io.Closer interfaces to the underlying object if they are available. 21 | type ReaderSeekerCloser struct { 22 | r io.Reader 23 | } 24 | 25 | // Read reads from the reader up to size of p. The number of bytes read, and 26 | // error if it occurred will be returned. 27 | // 28 | // If the reader is not an io.Reader zero bytes read, and nil error will be returned. 29 | // 30 | // Performs the same functionality as io.Reader Read 31 | func (r ReaderSeekerCloser) Read(p []byte) (int, error) { 32 | switch t := r.r.(type) { 33 | case io.Reader: 34 | return t.Read(p) 35 | } 36 | return 0, nil 37 | } 38 | 39 | // Seek sets the offset for the next Read to offset, interpreted according to 40 | // whence: 0 means relative to the origin of the file, 1 means relative to the 41 | // current offset, and 2 means relative to the end. Seek returns the new offset 42 | // and an error, if any. 43 | // 44 | // If the ReaderSeekerCloser is not an io.Seeker nothing will be done. 45 | func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error) { 46 | switch t := r.r.(type) { 47 | case io.Seeker: 48 | return t.Seek(offset, whence) 49 | } 50 | return int64(0), nil 51 | } 52 | 53 | // IsSeeker returns if the underlying reader is also a seeker. 54 | func (r ReaderSeekerCloser) IsSeeker() bool { 55 | _, ok := r.r.(io.Seeker) 56 | return ok 57 | } 58 | 59 | // Close closes the ReaderSeekerCloser. 60 | // 61 | // If the ReaderSeekerCloser is not an io.Closer nothing will be done. 62 | func (r ReaderSeekerCloser) Close() error { 63 | switch t := r.r.(type) { 64 | case io.Closer: 65 | return t.Close() 66 | } 67 | return nil 68 | } 69 | 70 | // A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface 71 | // Can be used with the s3manager.Downloader to download content to a buffer 72 | // in memory. Safe to use concurrently. 73 | type WriteAtBuffer struct { 74 | buf []byte 75 | m sync.Mutex 76 | 77 | // GrowthCoeff defines the growth rate of the internal buffer. By 78 | // default, the growth rate is 1, where expanding the internal 79 | // buffer will allocate only enough capacity to fit the new expected 80 | // length. 81 | GrowthCoeff float64 82 | } 83 | 84 | // NewWriteAtBuffer creates a WriteAtBuffer with an internal buffer 85 | // provided by buf. 86 | func NewWriteAtBuffer(buf []byte) *WriteAtBuffer { 87 | return &WriteAtBuffer{buf: buf} 88 | } 89 | 90 | // WriteAt writes a slice of bytes to a buffer starting at the position provided 91 | // The number of bytes written will be returned, or error. Can overwrite previous 92 | // written slices if the write ats overlap. 93 | func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error) { 94 | pLen := len(p) 95 | expLen := pos + int64(pLen) 96 | b.m.Lock() 97 | defer b.m.Unlock() 98 | if int64(len(b.buf)) < expLen { 99 | if int64(cap(b.buf)) < expLen { 100 | if b.GrowthCoeff < 1 { 101 | b.GrowthCoeff = 1 102 | } 103 | newBuf := make([]byte, expLen, int64(b.GrowthCoeff*float64(expLen))) 104 | copy(newBuf, b.buf) 105 | b.buf = newBuf 106 | } 107 | b.buf = b.buf[:expLen] 108 | } 109 | copy(b.buf[pos:], p) 110 | return pLen, nil 111 | } 112 | 113 | // Bytes returns a slice of bytes written to the buffer. 114 | func (b *WriteAtBuffer) Bytes() []byte { 115 | b.m.Lock() 116 | defer b.m.Unlock() 117 | return b.buf[:len(b.buf):len(b.buf)] 118 | } 119 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/version.go: -------------------------------------------------------------------------------- 1 | // Package aws provides core functionality for making requests to AWS services. 2 | package aws 3 | 4 | // SDKName is the name of this AWS SDK 5 | const SDKName = "aws-sdk-go" 6 | 7 | // SDKVersion is the version of this SDK 8 | const SDKVersion = "1.6.15" 9 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/idempotency.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "crypto/rand" 5 | "fmt" 6 | "reflect" 7 | ) 8 | 9 | // RandReader is the random reader the protocol package will use to read 10 | // random bytes from. This is exported for testing, and should not be used. 11 | var RandReader = rand.Reader 12 | 13 | const idempotencyTokenFillTag = `idempotencyToken` 14 | 15 | // CanSetIdempotencyToken returns true if the struct field should be 16 | // automatically populated with a Idempotency token. 17 | // 18 | // Only *string and string type fields that are tagged with idempotencyToken 19 | // which are not already set can be auto filled. 20 | func CanSetIdempotencyToken(v reflect.Value, f reflect.StructField) bool { 21 | switch u := v.Interface().(type) { 22 | // To auto fill an Idempotency token the field must be a string, 23 | // tagged for auto fill, and have a zero value. 24 | case *string: 25 | return u == nil && len(f.Tag.Get(idempotencyTokenFillTag)) != 0 26 | case string: 27 | return len(u) == 0 && len(f.Tag.Get(idempotencyTokenFillTag)) != 0 28 | } 29 | 30 | return false 31 | } 32 | 33 | // GetIdempotencyToken returns a randomly generated idempotency token. 34 | func GetIdempotencyToken() string { 35 | b := make([]byte, 16) 36 | RandReader.Read(b) 37 | 38 | return UUIDVersion4(b) 39 | } 40 | 41 | // SetIdempotencyToken will set the value provided with a Idempotency Token. 42 | // Given that the value can be set. Will panic if value is not setable. 43 | func SetIdempotencyToken(v reflect.Value) { 44 | if v.Kind() == reflect.Ptr { 45 | if v.IsNil() && v.CanSet() { 46 | v.Set(reflect.New(v.Type().Elem())) 47 | } 48 | v = v.Elem() 49 | } 50 | v = reflect.Indirect(v) 51 | 52 | if !v.CanSet() { 53 | panic(fmt.Sprintf("unable to set idempotnecy token %v", v)) 54 | } 55 | 56 | b := make([]byte, 16) 57 | _, err := rand.Read(b) 58 | if err != nil { 59 | // TODO handle error 60 | return 61 | } 62 | 63 | v.Set(reflect.ValueOf(UUIDVersion4(b))) 64 | } 65 | 66 | // UUIDVersion4 returns a Version 4 random UUID from the byte slice provided 67 | func UUIDVersion4(u []byte) string { 68 | // https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29 69 | // 13th character is "4" 70 | u[6] = (u[6] | 0x40) & 0x4F 71 | // 17th character is "8", "9", "a", or "b" 72 | u[8] = (u[8] | 0x80) & 0xBF 73 | 74 | return fmt.Sprintf(`%X-%X-%X-%X-%X`, u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/jsonrpc/jsonrpc.go: -------------------------------------------------------------------------------- 1 | // Package jsonrpc provides JSON RPC utilities for serialization of AWS 2 | // requests and responses. 3 | package jsonrpc 4 | 5 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/json.json build_test.go 6 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/json.json unmarshal_test.go 7 | 8 | import ( 9 | "encoding/json" 10 | "io/ioutil" 11 | "strings" 12 | 13 | "github.com/aws/aws-sdk-go/aws/awserr" 14 | "github.com/aws/aws-sdk-go/aws/request" 15 | "github.com/aws/aws-sdk-go/private/protocol/json/jsonutil" 16 | "github.com/aws/aws-sdk-go/private/protocol/rest" 17 | ) 18 | 19 | var emptyJSON = []byte("{}") 20 | 21 | // BuildHandler is a named request handler for building jsonrpc protocol requests 22 | var BuildHandler = request.NamedHandler{Name: "awssdk.jsonrpc.Build", Fn: Build} 23 | 24 | // UnmarshalHandler is a named request handler for unmarshaling jsonrpc protocol requests 25 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.jsonrpc.Unmarshal", Fn: Unmarshal} 26 | 27 | // UnmarshalMetaHandler is a named request handler for unmarshaling jsonrpc protocol request metadata 28 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.jsonrpc.UnmarshalMeta", Fn: UnmarshalMeta} 29 | 30 | // UnmarshalErrorHandler is a named request handler for unmarshaling jsonrpc protocol request errors 31 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.jsonrpc.UnmarshalError", Fn: UnmarshalError} 32 | 33 | // Build builds a JSON payload for a JSON RPC request. 34 | func Build(req *request.Request) { 35 | var buf []byte 36 | var err error 37 | if req.ParamsFilled() { 38 | buf, err = jsonutil.BuildJSON(req.Params) 39 | if err != nil { 40 | req.Error = awserr.New("SerializationError", "failed encoding JSON RPC request", err) 41 | return 42 | } 43 | } else { 44 | buf = emptyJSON 45 | } 46 | 47 | if req.ClientInfo.TargetPrefix != "" || string(buf) != "{}" { 48 | req.SetBufferBody(buf) 49 | } 50 | 51 | if req.ClientInfo.TargetPrefix != "" { 52 | target := req.ClientInfo.TargetPrefix + "." + req.Operation.Name 53 | req.HTTPRequest.Header.Add("X-Amz-Target", target) 54 | } 55 | if req.ClientInfo.JSONVersion != "" { 56 | jsonVersion := req.ClientInfo.JSONVersion 57 | req.HTTPRequest.Header.Add("Content-Type", "application/x-amz-json-"+jsonVersion) 58 | } 59 | } 60 | 61 | // Unmarshal unmarshals a response for a JSON RPC service. 62 | func Unmarshal(req *request.Request) { 63 | defer req.HTTPResponse.Body.Close() 64 | if req.DataFilled() { 65 | err := jsonutil.UnmarshalJSON(req.Data, req.HTTPResponse.Body) 66 | if err != nil { 67 | req.Error = awserr.New("SerializationError", "failed decoding JSON RPC response", err) 68 | } 69 | } 70 | return 71 | } 72 | 73 | // UnmarshalMeta unmarshals headers from a response for a JSON RPC service. 74 | func UnmarshalMeta(req *request.Request) { 75 | rest.UnmarshalMeta(req) 76 | } 77 | 78 | // UnmarshalError unmarshals an error response for a JSON RPC service. 79 | func UnmarshalError(req *request.Request) { 80 | defer req.HTTPResponse.Body.Close() 81 | bodyBytes, err := ioutil.ReadAll(req.HTTPResponse.Body) 82 | if err != nil { 83 | req.Error = awserr.New("SerializationError", "failed reading JSON RPC error response", err) 84 | return 85 | } 86 | if len(bodyBytes) == 0 { 87 | req.Error = awserr.NewRequestFailure( 88 | awserr.New("SerializationError", req.HTTPResponse.Status, nil), 89 | req.HTTPResponse.StatusCode, 90 | "", 91 | ) 92 | return 93 | } 94 | var jsonErr jsonErrorResponse 95 | if err := json.Unmarshal(bodyBytes, &jsonErr); err != nil { 96 | req.Error = awserr.New("SerializationError", "failed decoding JSON RPC error response", err) 97 | return 98 | } 99 | 100 | codes := strings.SplitN(jsonErr.Code, "#", 2) 101 | req.Error = awserr.NewRequestFailure( 102 | awserr.New(codes[len(codes)-1], jsonErr.Message, nil), 103 | req.HTTPResponse.StatusCode, 104 | req.RequestID, 105 | ) 106 | } 107 | 108 | type jsonErrorResponse struct { 109 | Code string `json:"__type"` 110 | Message string `json:"message"` 111 | } 112 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go: -------------------------------------------------------------------------------- 1 | // Package query provides serialization of AWS query requests, and responses. 2 | package query 3 | 4 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/query.json build_test.go 5 | 6 | import ( 7 | "net/url" 8 | 9 | "github.com/aws/aws-sdk-go/aws/awserr" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | "github.com/aws/aws-sdk-go/private/protocol/query/queryutil" 12 | ) 13 | 14 | // BuildHandler is a named request handler for building query protocol requests 15 | var BuildHandler = request.NamedHandler{Name: "awssdk.query.Build", Fn: Build} 16 | 17 | // Build builds a request for an AWS Query service. 18 | func Build(r *request.Request) { 19 | body := url.Values{ 20 | "Action": {r.Operation.Name}, 21 | "Version": {r.ClientInfo.APIVersion}, 22 | } 23 | if err := queryutil.Parse(body, r.Params, false); err != nil { 24 | r.Error = awserr.New("SerializationError", "failed encoding Query request", err) 25 | return 26 | } 27 | 28 | if r.ExpireTime == 0 { 29 | r.HTTPRequest.Method = "POST" 30 | r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") 31 | r.SetBufferBody([]byte(body.Encode())) 32 | } else { // This is a pre-signed request 33 | r.HTTPRequest.Method = "GET" 34 | r.HTTPRequest.URL.RawQuery = body.Encode() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/query.json unmarshal_test.go 4 | 5 | import ( 6 | "encoding/xml" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 11 | ) 12 | 13 | // UnmarshalHandler is a named request handler for unmarshaling query protocol requests 14 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.query.Unmarshal", Fn: Unmarshal} 15 | 16 | // UnmarshalMetaHandler is a named request handler for unmarshaling query protocol request metadata 17 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalMeta", Fn: UnmarshalMeta} 18 | 19 | // Unmarshal unmarshals a response for an AWS Query service. 20 | func Unmarshal(r *request.Request) { 21 | defer r.HTTPResponse.Body.Close() 22 | if r.DataFilled() { 23 | decoder := xml.NewDecoder(r.HTTPResponse.Body) 24 | err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result") 25 | if err != nil { 26 | r.Error = awserr.New("SerializationError", "failed decoding Query response", err) 27 | return 28 | } 29 | } 30 | } 31 | 32 | // UnmarshalMeta unmarshals header response values for an AWS Query service. 33 | func UnmarshalMeta(r *request.Request) { 34 | r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "encoding/xml" 5 | "io/ioutil" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | type xmlErrorResponse struct { 12 | XMLName xml.Name `xml:"ErrorResponse"` 13 | Code string `xml:"Error>Code"` 14 | Message string `xml:"Error>Message"` 15 | RequestID string `xml:"RequestId"` 16 | } 17 | 18 | type xmlServiceUnavailableResponse struct { 19 | XMLName xml.Name `xml:"ServiceUnavailableException"` 20 | } 21 | 22 | // UnmarshalErrorHandler is a name request handler to unmarshal request errors 23 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalError", Fn: UnmarshalError} 24 | 25 | // UnmarshalError unmarshals an error response for an AWS Query service. 26 | func UnmarshalError(r *request.Request) { 27 | defer r.HTTPResponse.Body.Close() 28 | 29 | bodyBytes, err := ioutil.ReadAll(r.HTTPResponse.Body) 30 | if err != nil { 31 | r.Error = awserr.New("SerializationError", "failed to read from query HTTP response body", err) 32 | return 33 | } 34 | 35 | // First check for specific error 36 | resp := xmlErrorResponse{} 37 | decodeErr := xml.Unmarshal(bodyBytes, &resp) 38 | if decodeErr == nil { 39 | reqID := resp.RequestID 40 | if reqID == "" { 41 | reqID = r.RequestID 42 | } 43 | r.Error = awserr.NewRequestFailure( 44 | awserr.New(resp.Code, resp.Message, nil), 45 | r.HTTPResponse.StatusCode, 46 | reqID, 47 | ) 48 | return 49 | } 50 | 51 | // Check for unhandled error 52 | servUnavailResp := xmlServiceUnavailableResponse{} 53 | unavailErr := xml.Unmarshal(bodyBytes, &servUnavailResp) 54 | if unavailErr == nil { 55 | r.Error = awserr.NewRequestFailure( 56 | awserr.New("ServiceUnavailableException", "service is unavailable", nil), 57 | r.HTTPResponse.StatusCode, 58 | r.RequestID, 59 | ) 60 | return 61 | } 62 | 63 | // Failed to retrieve any error message from the response body 64 | r.Error = awserr.New("SerializationError", 65 | "failed to decode query XML error response", decodeErr) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import "reflect" 4 | 5 | // PayloadMember returns the payload field member of i if there is one, or nil. 6 | func PayloadMember(i interface{}) interface{} { 7 | if i == nil { 8 | return nil 9 | } 10 | 11 | v := reflect.ValueOf(i).Elem() 12 | if !v.IsValid() { 13 | return nil 14 | } 15 | if field, ok := v.Type().FieldByName("_"); ok { 16 | if payloadName := field.Tag.Get("payload"); payloadName != "" { 17 | field, _ := v.Type().FieldByName(payloadName) 18 | if field.Tag.Get("type") != "structure" { 19 | return nil 20 | } 21 | 22 | payload := v.FieldByName(payloadName) 23 | if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) { 24 | return payload.Interface() 25 | } 26 | } 27 | } 28 | return nil 29 | } 30 | 31 | // PayloadType returns the type of a payload field member of i if there is one, or "". 32 | func PayloadType(i interface{}) string { 33 | v := reflect.Indirect(reflect.ValueOf(i)) 34 | if !v.IsValid() { 35 | return "" 36 | } 37 | if field, ok := v.Type().FieldByName("_"); ok { 38 | if payloadName := field.Tag.Get("payload"); payloadName != "" { 39 | if member, ok := v.Type().FieldByName(payloadName); ok { 40 | return member.Tag.Get("type") 41 | } 42 | } 43 | } 44 | return "" 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/unmarshal.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | 7 | "github.com/aws/aws-sdk-go/aws/request" 8 | ) 9 | 10 | // UnmarshalDiscardBodyHandler is a named request handler to empty and close a response's body 11 | var UnmarshalDiscardBodyHandler = request.NamedHandler{Name: "awssdk.shared.UnmarshalDiscardBody", Fn: UnmarshalDiscardBody} 12 | 13 | // UnmarshalDiscardBody is a request handler to empty a response's body and closing it. 14 | func UnmarshalDiscardBody(r *request.Request) { 15 | if r.HTTPResponse == nil || r.HTTPResponse.Body == nil { 16 | return 17 | } 18 | 19 | io.Copy(ioutil.Discard, r.HTTPResponse.Body) 20 | r.HTTPResponse.Body.Close() 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go: -------------------------------------------------------------------------------- 1 | package xmlutil 2 | 3 | import ( 4 | "encoding/xml" 5 | "fmt" 6 | "io" 7 | "sort" 8 | ) 9 | 10 | // A XMLNode contains the values to be encoded or decoded. 11 | type XMLNode struct { 12 | Name xml.Name `json:",omitempty"` 13 | Children map[string][]*XMLNode `json:",omitempty"` 14 | Text string `json:",omitempty"` 15 | Attr []xml.Attr `json:",omitempty"` 16 | 17 | namespaces map[string]string 18 | parent *XMLNode 19 | } 20 | 21 | // NewXMLElement returns a pointer to a new XMLNode initialized to default values. 22 | func NewXMLElement(name xml.Name) *XMLNode { 23 | return &XMLNode{ 24 | Name: name, 25 | Children: map[string][]*XMLNode{}, 26 | Attr: []xml.Attr{}, 27 | } 28 | } 29 | 30 | // AddChild adds child to the XMLNode. 31 | func (n *XMLNode) AddChild(child *XMLNode) { 32 | if _, ok := n.Children[child.Name.Local]; !ok { 33 | n.Children[child.Name.Local] = []*XMLNode{} 34 | } 35 | n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child) 36 | } 37 | 38 | // XMLToStruct converts a xml.Decoder stream to XMLNode with nested values. 39 | func XMLToStruct(d *xml.Decoder, s *xml.StartElement) (*XMLNode, error) { 40 | out := &XMLNode{} 41 | for { 42 | tok, err := d.Token() 43 | if tok == nil || err == io.EOF { 44 | break 45 | } 46 | if err != nil { 47 | return out, err 48 | } 49 | 50 | switch typed := tok.(type) { 51 | case xml.CharData: 52 | out.Text = string(typed.Copy()) 53 | case xml.StartElement: 54 | el := typed.Copy() 55 | out.Attr = el.Attr 56 | if out.Children == nil { 57 | out.Children = map[string][]*XMLNode{} 58 | } 59 | 60 | name := typed.Name.Local 61 | slice := out.Children[name] 62 | if slice == nil { 63 | slice = []*XMLNode{} 64 | } 65 | node, e := XMLToStruct(d, &el) 66 | out.findNamespaces() 67 | if e != nil { 68 | return out, e 69 | } 70 | node.Name = typed.Name 71 | node.findNamespaces() 72 | tempOut := *out 73 | // Save into a temp variable, simply because out gets squashed during 74 | // loop iterations 75 | node.parent = &tempOut 76 | slice = append(slice, node) 77 | out.Children[name] = slice 78 | case xml.EndElement: 79 | if s != nil && s.Name.Local == typed.Name.Local { // matching end token 80 | return out, nil 81 | } 82 | out = &XMLNode{} 83 | } 84 | } 85 | return out, nil 86 | } 87 | 88 | func (n *XMLNode) findNamespaces() { 89 | ns := map[string]string{} 90 | for _, a := range n.Attr { 91 | if a.Name.Space == "xmlns" { 92 | ns[a.Value] = a.Name.Local 93 | } 94 | } 95 | 96 | n.namespaces = ns 97 | } 98 | 99 | func (n *XMLNode) findElem(name string) (string, bool) { 100 | for node := n; node != nil; node = node.parent { 101 | for _, a := range node.Attr { 102 | namespace := a.Name.Space 103 | if v, ok := node.namespaces[namespace]; ok { 104 | namespace = v 105 | } 106 | if name == fmt.Sprintf("%s:%s", namespace, a.Name.Local) { 107 | return a.Value, true 108 | } 109 | } 110 | } 111 | return "", false 112 | } 113 | 114 | // StructToXML writes an XMLNode to a xml.Encoder as tokens. 115 | func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error { 116 | e.EncodeToken(xml.StartElement{Name: node.Name, Attr: node.Attr}) 117 | 118 | if node.Text != "" { 119 | e.EncodeToken(xml.CharData([]byte(node.Text))) 120 | } else if sorted { 121 | sortedNames := []string{} 122 | for k := range node.Children { 123 | sortedNames = append(sortedNames, k) 124 | } 125 | sort.Strings(sortedNames) 126 | 127 | for _, k := range sortedNames { 128 | for _, v := range node.Children[k] { 129 | StructToXML(e, v, sorted) 130 | } 131 | } 132 | } else { 133 | for _, c := range node.Children { 134 | for _, v := range c { 135 | StructToXML(e, v, sorted) 136 | } 137 | } 138 | } 139 | 140 | e.EncodeToken(xml.EndElement{Name: node.Name}) 141 | return e.Flush() 142 | } 143 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go: -------------------------------------------------------------------------------- 1 | package sts 2 | 3 | import "github.com/aws/aws-sdk-go/aws/request" 4 | 5 | func init() { 6 | initRequest = func(r *request.Request) { 7 | switch r.Operation.Name { 8 | case opAssumeRoleWithSAML, opAssumeRoleWithWebIdentity: 9 | r.Handlers.Sign.Clear() // these operations are unsigned 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test bench vet 2 | 3 | build: vet bench 4 | 5 | test: 6 | go test -v -cover -race 7 | 8 | bench: 9 | go test -v -cover -race -test.bench=. -test.benchmem 10 | 11 | vet: 12 | go vet 13 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // 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, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | type ErrDelimiterNotFound struct { 22 | Line string 23 | } 24 | 25 | func IsErrDelimiterNotFound(err error) bool { 26 | _, ok := err.(ErrDelimiterNotFound) 27 | return ok 28 | } 29 | 30 | func (err ErrDelimiterNotFound) Error() string { 31 | return fmt.Sprintf("key-value delimiter not found: %s", err.Line) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 James Saryerwinnie 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CMD = jpgo 3 | 4 | help: 5 | @echo "Please use \`make ' where is one of" 6 | @echo " test to run all the tests" 7 | @echo " build to build the library and jp executable" 8 | @echo " generate to run codegen" 9 | 10 | 11 | generate: 12 | go generate ./... 13 | 14 | build: 15 | rm -f $(CMD) 16 | go build ./... 17 | rm -f cmd/$(CMD)/$(CMD) && cd cmd/$(CMD)/ && go build ./... 18 | mv cmd/$(CMD)/$(CMD) . 19 | 20 | test: 21 | go test -v ./... 22 | 23 | check: 24 | go vet ./... 25 | @echo "golint ./..." 26 | @lint=`golint ./...`; \ 27 | lint=`echo "$$lint" | grep -v "astnodetype_string.go" | grep -v "toktype_string.go"`; \ 28 | echo "$$lint"; \ 29 | if [ "$$lint" != "" ]; then exit 1; fi 30 | 31 | htmlc: 32 | go test -coverprofile="/tmp/jpcov" && go tool cover -html="/tmp/jpcov" && unlink /tmp/jpcov 33 | 34 | buildfuzz: 35 | go-fuzz-build github.com/jmespath/go-jmespath/fuzz 36 | 37 | fuzz: buildfuzz 38 | go-fuzz -bin=./jmespath-fuzz.zip -workdir=fuzz/testdata 39 | 40 | bench: 41 | go test -bench . -cpuprofile cpu.out 42 | 43 | pprof-cpu: 44 | go tool pprof ./go-jmespath.test ./cpu.out 45 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/README.md: -------------------------------------------------------------------------------- 1 | # go-jmespath - A JMESPath implementation in Go 2 | 3 | [![Build Status](https://img.shields.io/travis/jmespath/go-jmespath.svg)](https://travis-ci.org/jmespath/go-jmespath) 4 | 5 | 6 | 7 | See http://jmespath.org for more info. 8 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/api.go: -------------------------------------------------------------------------------- 1 | package jmespath 2 | 3 | import "strconv" 4 | 5 | // JmesPath is the epresentation of a compiled JMES path query. A JmesPath is 6 | // safe for concurrent use by multiple goroutines. 7 | type JMESPath struct { 8 | ast ASTNode 9 | intr *treeInterpreter 10 | } 11 | 12 | // Compile parses a JMESPath expression and returns, if successful, a JMESPath 13 | // object that can be used to match against data. 14 | func Compile(expression string) (*JMESPath, error) { 15 | parser := NewParser() 16 | ast, err := parser.Parse(expression) 17 | if err != nil { 18 | return nil, err 19 | } 20 | jmespath := &JMESPath{ast: ast, intr: newInterpreter()} 21 | return jmespath, nil 22 | } 23 | 24 | // MustCompile is like Compile but panics if the expression cannot be parsed. 25 | // It simplifies safe initialization of global variables holding compiled 26 | // JMESPaths. 27 | func MustCompile(expression string) *JMESPath { 28 | jmespath, err := Compile(expression) 29 | if err != nil { 30 | panic(`jmespath: Compile(` + strconv.Quote(expression) + `): ` + err.Error()) 31 | } 32 | return jmespath 33 | } 34 | 35 | // Search evaluates a JMESPath expression against input data and returns the result. 36 | func (jp *JMESPath) Search(data interface{}) (interface{}, error) { 37 | return jp.intr.Execute(jp.ast, data) 38 | } 39 | 40 | // Search evaluates a JMESPath expression against input data and returns the result. 41 | func Search(expression string, data interface{}) (interface{}, error) { 42 | intr := newInterpreter() 43 | parser := NewParser() 44 | ast, err := parser.Parse(expression) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return intr.Execute(ast, data) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/astnodetype_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type astNodeType; DO NOT EDIT 2 | 3 | package jmespath 4 | 5 | import "fmt" 6 | 7 | const _astNodeType_name = "ASTEmptyASTComparatorASTCurrentNodeASTExpRefASTFunctionExpressionASTFieldASTFilterProjectionASTFlattenASTIdentityASTIndexASTIndexExpressionASTKeyValPairASTLiteralASTMultiSelectHashASTMultiSelectListASTOrExpressionASTAndExpressionASTNotExpressionASTPipeASTProjectionASTSubexpressionASTSliceASTValueProjection" 8 | 9 | var _astNodeType_index = [...]uint16{0, 8, 21, 35, 44, 65, 73, 92, 102, 113, 121, 139, 152, 162, 180, 198, 213, 229, 245, 252, 265, 281, 289, 307} 10 | 11 | func (i astNodeType) String() string { 12 | if i < 0 || i >= astNodeType(len(_astNodeType_index)-1) { 13 | return fmt.Sprintf("astNodeType(%d)", i) 14 | } 15 | return _astNodeType_name[_astNodeType_index[i]:_astNodeType_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/toktype_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type=tokType; DO NOT EDIT 2 | 3 | package jmespath 4 | 5 | import "fmt" 6 | 7 | const _tokType_name = "tUnknowntStartDottFiltertFlattentLparentRparentLbrackettRbrackettLbracetRbracetOrtPipetNumbertUnquotedIdentifiertQuotedIdentifiertCommatColontLTtLTEtGTtGTEtEQtNEtJSONLiteraltStringLiteraltCurrenttExpreftAndtNottEOF" 8 | 9 | var _tokType_index = [...]uint8{0, 8, 13, 17, 24, 32, 39, 46, 55, 64, 71, 78, 81, 86, 93, 112, 129, 135, 141, 144, 148, 151, 155, 158, 161, 173, 187, 195, 202, 206, 210, 214} 10 | 11 | func (i tokType) String() string { 12 | if i < 0 || i >= tokType(len(_tokType_index)-1) { 13 | return fmt.Sprintf("tokType(%d)", i) 14 | } 15 | return _tokType_name[_tokType_index[i]:_tokType_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/http_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "net/url" 8 | "strings" 9 | ) 10 | 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 12 | // if building a new request fails. 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int { 14 | w := httptest.NewRecorder() 15 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 16 | if err != nil { 17 | return -1 18 | } 19 | handler(w, req) 20 | return w.Code 21 | } 22 | 23 | // HTTPSuccess asserts that a specified handler returns a success status code. 24 | // 25 | // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 26 | // 27 | // Returns whether the assertion was successful (true) or not (false). 28 | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 29 | code := httpCode(handler, method, url, values) 30 | if code == -1 { 31 | return false 32 | } 33 | return code >= http.StatusOK && code <= http.StatusPartialContent 34 | } 35 | 36 | // HTTPRedirect asserts that a specified handler returns a redirect status code. 37 | // 38 | // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 39 | // 40 | // Returns whether the assertion was successful (true) or not (false). 41 | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 42 | code := httpCode(handler, method, url, values) 43 | if code == -1 { 44 | return false 45 | } 46 | return code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect 47 | } 48 | 49 | // HTTPError asserts that a specified handler returns an error status code. 50 | // 51 | // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 52 | // 53 | // Returns whether the assertion was successful (true) or not (false). 54 | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 55 | code := httpCode(handler, method, url, values) 56 | if code == -1 { 57 | return false 58 | } 59 | return code >= http.StatusBadRequest 60 | } 61 | 62 | // HTTPBody is a helper that returns HTTP body of the response. It returns 63 | // empty string if building a new request fails. 64 | func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { 65 | w := httptest.NewRecorder() 66 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 67 | if err != nil { 68 | return "" 69 | } 70 | handler(w, req) 71 | return w.Body.String() 72 | } 73 | 74 | // HTTPBodyContains asserts that a specified handler returns a 75 | // body that contains a string. 76 | // 77 | // assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 78 | // 79 | // Returns whether the assertion was successful (true) or not (false). 80 | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 81 | body := HTTPBody(handler, method, url, values) 82 | 83 | contains := strings.Contains(body, fmt.Sprint(str)) 84 | if !contains { 85 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 86 | } 87 | 88 | return contains 89 | } 90 | 91 | // HTTPBodyNotContains asserts that a specified handler returns a 92 | // body that does not contain a string. 93 | // 94 | // assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 95 | // 96 | // Returns whether the assertion was successful (true) or not (false). 97 | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 98 | body := HTTPBody(handler, method, url, values) 99 | 100 | contains := strings.Contains(body, fmt.Sprint(str)) 101 | if contains { 102 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 103 | } 104 | 105 | return !contains 106 | } 107 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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_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 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/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /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.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /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_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/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 | --------------------------------------------------------------------------------