├── .gitignore ├── CONTRIBUTING.md ├── DCO ├── Dockerfile ├── LICENSE ├── NOTICE ├── README.md ├── aws-auth-proxy.go ├── code-of-conduct.md ├── glide.lock ├── glide.yaml └── vendor ├── github.com ├── bitly │ └── go-simplejson │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── simplejson.go │ │ ├── simplejson_go10.go │ │ ├── simplejson_go10_test.go │ │ ├── simplejson_go11.go │ │ ├── simplejson_go11_test.go │ │ └── simplejson_test.go ├── coreos │ ├── go-systemd │ │ ├── .travis.yml │ │ ├── CONTRIBUTING.md │ │ ├── DCO │ │ ├── LICENSE │ │ ├── README.md │ │ ├── activation │ │ │ ├── files.go │ │ │ ├── files_test.go │ │ │ ├── listeners.go │ │ │ ├── listeners_test.go │ │ │ ├── packetconns.go │ │ │ └── packetconns_test.go │ │ ├── daemon │ │ │ └── sdnotify.go │ │ ├── dbus │ │ │ ├── dbus.go │ │ │ ├── dbus_test.go │ │ │ ├── methods.go │ │ │ ├── methods_test.go │ │ │ ├── properties.go │ │ │ ├── set.go │ │ │ ├── set_test.go │ │ │ ├── subscription.go │ │ │ ├── subscription_set.go │ │ │ ├── subscription_set_test.go │ │ │ └── subscription_test.go │ │ ├── examples │ │ │ └── activation │ │ │ │ ├── activation.go │ │ │ │ ├── httpserver │ │ │ │ ├── README.md │ │ │ │ ├── hello.service │ │ │ │ ├── hello.socket │ │ │ │ └── httpserver.go │ │ │ │ ├── listen.go │ │ │ │ └── udpconn.go │ │ ├── fixtures │ │ │ ├── enable-disable.service │ │ │ ├── start-stop.service │ │ │ ├── subscribe-events-set.service │ │ │ └── subscribe-events.service │ │ ├── journal │ │ │ └── journal.go │ │ ├── login1 │ │ │ ├── dbus.go │ │ │ └── dbus_test.go │ │ ├── machine1 │ │ │ ├── dbus.go │ │ │ └── dbus_test.go │ │ ├── sdjournal │ │ │ ├── journal.go │ │ │ ├── journal_test.go │ │ │ └── read.go │ │ ├── test │ │ ├── unit │ │ │ ├── deserialize.go │ │ │ ├── deserialize_test.go │ │ │ ├── end_to_end_test.go │ │ │ ├── escape.go │ │ │ ├── escape_test.go │ │ │ ├── option.go │ │ │ ├── option_test.go │ │ │ ├── serialize.go │ │ │ └── serialize_test.go │ │ └── util │ │ │ └── util.go │ └── pkg │ │ ├── .gitignore │ │ ├── CONTRIBUTING.md │ │ ├── DCO │ │ ├── LICENSE │ │ ├── MAINTAINERS │ │ ├── NOTICE │ │ ├── README.md │ │ ├── build │ │ ├── capnslog │ │ ├── README.md │ │ ├── example │ │ │ └── hello_dolly.go │ │ ├── formatters.go │ │ ├── glog_formatter.go │ │ ├── init.go │ │ ├── init_windows.go │ │ ├── journald_formatter.go │ │ ├── log_hijack.go │ │ ├── logmap.go │ │ ├── pkg_logger.go │ │ └── syslog_formatter.go │ │ ├── cryptoutil │ │ ├── aes.go │ │ └── aes_test.go │ │ ├── flagutil │ │ ├── env.go │ │ ├── env_test.go │ │ ├── types.go │ │ └── types_test.go │ │ ├── health │ │ ├── README.md │ │ ├── health.go │ │ └── health_test.go │ │ ├── httputil │ │ ├── README.md │ │ ├── cookie.go │ │ ├── cookie_test.go │ │ ├── json.go │ │ └── json_test.go │ │ ├── multierror │ │ ├── multierror.go │ │ └── multierror_test.go │ │ ├── netutil │ │ ├── proxy.go │ │ ├── url.go │ │ └── url_test.go │ │ ├── test │ │ ├── timeutil │ │ ├── backoff.go │ │ └── backoff_test.go │ │ └── yamlutil │ │ ├── yaml.go │ │ └── yaml_test.go ├── crowdmob │ └── goamz │ │ ├── .gitignore │ │ ├── .lbox │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── TODO.md │ │ ├── autoscaling │ │ ├── astest │ │ │ ├── http.go │ │ │ └── responses.go │ │ ├── autoscaling.go │ │ ├── autoscaling_test.go │ │ └── sign.go │ │ ├── aws │ │ ├── attempt.go │ │ ├── attempt_test.go │ │ ├── aws.go │ │ ├── aws_test.go │ │ ├── client.go │ │ ├── export_test.go │ │ ├── regions.go │ │ ├── retry.go │ │ ├── retry_test.go │ │ ├── sign.go │ │ └── sign_test.go │ │ ├── cloudfront │ │ ├── cloudfront.go │ │ ├── cloudfront_test.go │ │ └── testdata │ │ │ ├── key.pem │ │ │ └── key.pub │ │ ├── cloudwatch │ │ ├── ChangeLog │ │ ├── README.md │ │ ├── cloudwatch.go │ │ └── cloudwatch_test.go │ │ ├── dynamodb │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.md │ │ ├── attribute.go │ │ ├── dynamizer │ │ │ ├── dynamizer.go │ │ │ └── dynamizer_test.go │ │ ├── dynamo_query_builder.go │ │ ├── dynamo_query_builder_test.go │ │ ├── dynamodb.go │ │ ├── dynamodb_test.go │ │ ├── item.go │ │ ├── item_test.go │ │ ├── marshaller.go │ │ ├── marshaller_test.go │ │ ├── query.go │ │ ├── query_builder.go │ │ ├── query_builder_test.go │ │ ├── retry_test.go │ │ ├── scan.go │ │ ├── table.go │ │ └── table_test.go │ │ ├── ec2 │ │ ├── ec2.go │ │ ├── ec2_test.go │ │ ├── ec2i_test.go │ │ ├── ec2t_test.go │ │ ├── ec2test │ │ │ ├── filter.go │ │ │ └── server.go │ │ ├── export_test.go │ │ ├── responses_test.go │ │ ├── sign.go │ │ └── sign_test.go │ │ ├── ecommerce │ │ └── ecommerce.go │ │ ├── elasticache │ │ ├── elasticache.go │ │ ├── elasticache_test.go │ │ └── responses_test.go │ │ ├── elb │ │ ├── elb.go │ │ ├── elb_test.go │ │ ├── elbi_test.go │ │ ├── elbt_test.go │ │ ├── elbtest │ │ │ └── server.go │ │ ├── response_test.go │ │ └── suite_test.go │ │ ├── exp │ │ ├── mturk │ │ │ ├── example_test.go │ │ │ ├── export_test.go │ │ │ ├── mturk.go │ │ │ ├── mturk_test.go │ │ │ ├── responses_test.go │ │ │ ├── sign.go │ │ │ └── sign_test.go │ │ ├── sdb │ │ │ ├── export_test.go │ │ │ ├── responses_test.go │ │ │ ├── sdb.go │ │ │ ├── sdb_test.go │ │ │ ├── sign.go │ │ │ └── sign_test.go │ │ └── ses │ │ │ ├── delivery_notification.go │ │ │ ├── delivery_notification_requests_test.go │ │ │ ├── delivery_notification_test.go │ │ │ ├── mailbox_simulator.go │ │ │ ├── responses_test.go │ │ │ ├── ses.go │ │ │ └── ses_test.go │ │ ├── iam │ │ ├── iam.go │ │ ├── iam_test.go │ │ ├── iami_test.go │ │ ├── iamt_test.go │ │ ├── iamtest │ │ │ └── server.go │ │ ├── responses_test.go │ │ └── sign.go │ │ ├── kinesis │ │ ├── kinesis.go │ │ ├── kinesis_test.go │ │ ├── query.go │ │ ├── responses_test.go │ │ └── types.go │ │ ├── rds │ │ ├── rds.go │ │ ├── rds_test.go │ │ ├── responses_test.go │ │ └── types.go │ │ ├── route53 │ │ └── route53.go │ │ ├── s3 │ │ ├── export_test.go │ │ ├── lifecycle.go │ │ ├── lifecycle_test.go │ │ ├── multi.go │ │ ├── multi_test.go │ │ ├── responses_test.go │ │ ├── s3.go │ │ ├── s3_test.go │ │ ├── s3i_test.go │ │ ├── s3t_test.go │ │ ├── s3test │ │ │ └── server.go │ │ ├── sign.go │ │ └── sign_test.go │ │ ├── sns │ │ ├── http_notifications.go │ │ ├── http_notifications_test.go │ │ ├── responses_test.go │ │ ├── sns.go │ │ ├── sns_test.go │ │ └── structs.go │ │ ├── sqs │ │ ├── Makefile │ │ ├── README.md │ │ ├── md5.go │ │ ├── responses_test.go │ │ ├── sign.go │ │ ├── sqs.go │ │ ├── sqs_test.go │ │ └── suite_test.go │ │ ├── sts │ │ ├── responses_test.go │ │ ├── sts.go │ │ └── sts_test.go │ │ └── testutil │ │ ├── http.go │ │ └── suite.go ├── feyeleanor │ ├── raw │ │ ├── LICENSE │ │ ├── README │ │ ├── byte_slice.go │ │ ├── byte_slice_test.go │ │ ├── reslice.go │ │ ├── reslice_test.go │ │ ├── runtime.go │ │ ├── runtime_test.go │ │ ├── type.go │ │ └── type_test.go │ ├── sets │ │ ├── LICENSE │ │ ├── README │ │ ├── complex128.go │ │ ├── complex128_test.go │ │ ├── complex64.go │ │ ├── complex64_test.go │ │ ├── error.go │ │ ├── error_test.go │ │ ├── float32.go │ │ ├── float32_test.go │ │ ├── float64.go │ │ ├── float64_test.go │ │ ├── int.go │ │ ├── int16.go │ │ ├── int16_test.go │ │ ├── int32.go │ │ ├── int32_test.go │ │ ├── int64.go │ │ ├── int64_test.go │ │ ├── int8.go │ │ ├── int8_test.go │ │ ├── int_test.go │ │ ├── set.go │ │ ├── set_test.go │ │ ├── sets.go │ │ ├── sets_test.go │ │ ├── string.go │ │ ├── string_test.go │ │ ├── uint.go │ │ ├── uint16.go │ │ ├── uint16_test.go │ │ ├── uint32.go │ │ ├── uint32_test.go │ │ ├── uint64.go │ │ ├── uint64_test.go │ │ ├── uint8.go │ │ ├── uint8_test.go │ │ ├── uint_test.go │ │ ├── uintptr.go │ │ └── uintptr_test.go │ └── slices │ │ ├── LICENSE │ │ ├── README │ │ ├── complex128.go │ │ ├── complex128_test.go │ │ ├── complex64.go │ │ ├── complex64_benchmark_test.go │ │ ├── complex64_test.go │ │ ├── error.go │ │ ├── error_test.go │ │ ├── float32.go │ │ ├── float32_test.go │ │ ├── float64.go │ │ ├── float64_test.go │ │ ├── int.go │ │ ├── int16.go │ │ ├── int16_test.go │ │ ├── int32.go │ │ ├── int32_test.go │ │ ├── int64.go │ │ ├── int64_test.go │ │ ├── int8.go │ │ ├── int8_test.go │ │ ├── int_test.go │ │ ├── reflected.go │ │ ├── reflected_test.go │ │ ├── slice.go │ │ ├── slice_test.go │ │ ├── slices.go │ │ ├── slices_test.go │ │ ├── string.go │ │ ├── string_test.go │ │ ├── uint.go │ │ ├── uint16.go │ │ ├── uint16_test.go │ │ ├── uint32.go │ │ ├── uint32_test.go │ │ ├── uint64.go │ │ ├── uint64_test.go │ │ ├── uint8.go │ │ ├── uint8_test.go │ │ ├── uint_test.go │ │ ├── uintptr.go │ │ ├── uintptr_test.go │ │ ├── value.go │ │ └── value_test.go └── godbus │ └── dbus │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── MAINTAINERS │ ├── README.markdown │ ├── _examples │ ├── eavesdrop.go │ ├── introspect.go │ ├── list-names.go │ ├── notification.go │ ├── prop.go │ ├── server.go │ └── signal.go │ ├── auth.go │ ├── auth_external.go │ ├── auth_sha1.go │ ├── call.go │ ├── conn.go │ ├── conn_darwin.go │ ├── conn_other.go │ ├── conn_test.go │ ├── dbus.go │ ├── decoder.go │ ├── doc.go │ ├── encoder.go │ ├── encoder_test.go │ ├── examples_test.go │ ├── export.go │ ├── export_test.go │ ├── homedir.go │ ├── homedir_dynamic.go │ ├── homedir_static.go │ ├── introspect │ ├── call.go │ ├── introspect.go │ └── introspectable.go │ ├── message.go │ ├── object.go │ ├── prop │ └── prop.go │ ├── proto_test.go │ ├── sig.go │ ├── sig_test.go │ ├── transport_darwin.go │ ├── transport_generic.go │ ├── transport_unix.go │ ├── transport_unix_test.go │ ├── transport_unixcred_dragonfly.go │ ├── transport_unixcred_linux.go │ ├── variant.go │ ├── variant_lexer.go │ ├── variant_parser.go │ └── variant_test.go └── gopkg.in ├── check.v1 ├── .gitignore ├── LICENSE ├── README.md ├── TODO ├── benchmark.go ├── benchmark_test.go ├── bootstrap_test.go ├── check.go ├── check_test.go ├── checkers.go ├── checkers_test.go ├── export_test.go ├── fixture_test.go ├── foundation_test.go ├── helpers.go ├── helpers_test.go ├── printer.go ├── printer_test.go ├── reporter.go ├── reporter_test.go ├── run.go └── run_test.go └── yaml.v1 ├── LICENSE ├── LICENSE.libyaml ├── README.md ├── apic.go ├── decode.go ├── decode_test.go ├── emitterc.go ├── encode.go ├── encode_test.go ├── parserc.go ├── readerc.go ├── resolve.go ├── scannerc.go ├── sorter.go ├── suite_test.go ├── writerc.go ├── yaml.go ├── yamlh.go └── yamlprivateh.go /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.10.1 2 | MAINTAINER cohom@redhat.com 3 | 4 | WORKDIR $GOPATH/src/github.com/coreos 5 | ADD . ./aws-auth-proxy 6 | WORKDIR ./aws-auth-proxy 7 | RUN go install github.com/coreos/aws-auth-proxy 8 | 9 | ENTRYPOINT ["aws-auth-proxy"] 10 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2015 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #aws-auth-proxy 2 | 3 | [![Docker Repository on Quay](https://quay.io/repository/coreos/aws-auth-proxy/status "Docker Repository on Quay")](https://quay.io/repository/coreos/aws-auth-proxy) 4 | 5 | ##Installation 6 | 7 | pre-reqs: 8 | * go1.5 9 | * [glide package manager](https://github.com/Masterminds/glide) 10 | 11 | ```sh 12 | #requires go1.5 13 | export GO15VENDOREXPERIMENT=1 14 | 15 | mkdir -p $GOPATH/src/github.com/coreos 16 | cd $GOPATH/src/github.com/coreos 17 | git clone https://github.com/coreos/aws-auth-proxy 18 | cd aws-auth-proxy 19 | glide install 20 | go build github.com/coreos/aws-auth-proxy 21 | ``` 22 | ##Example 23 | 24 | ```sh 25 | # aws elasticsearch example 26 | ./aws-auth-proxy \ 27 | -access-key=xxx \ 28 | -secret-key=xxxx \ 29 | -service-name=es \ 30 | -region-name= \ 31 | -upstream-host= \ 32 | -upstream-scheme=https \ 33 | -listen-address=":9200" 34 | ``` 35 | 36 | Your proxied elasticsearch endpoint is now here: [http://localhost:9200](http://localhost:9200) 37 | 38 | 39 | No more securing elastic search endpoints with IP addresses! 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /glide.lock: -------------------------------------------------------------------------------- 1 | hash: 0780fbea7c27c05ae519e0ce0885bda427b511064c36932175931c8fb8bf6b5d 2 | updated: 2016-01-12T23:57:13.531719273-08:00 3 | imports: 4 | - name: github.com/bitly/go-simplejson 5 | version: aabad6e819789e569bd6aabf444c935aa9ba1e44 6 | repo: https://github.com/bitly/go-simplejson 7 | - name: github.com/coreos/go-systemd 8 | version: dd4f6b87c2a80813d1a01790344322da19ff195e 9 | repo: https://github.com/coreos/go-systemd 10 | - name: github.com/coreos/pkg 11 | version: 2c77715c4df99b5420ffcae14ead08f52104065d 12 | subpackages: 13 | - /flagutil 14 | - name: github.com/crowdmob/goamz 15 | version: 3a06871fe9fc0281ca90f3a7d97258d042ed64c0 16 | subpackages: 17 | - /aws 18 | - name: github.com/feyeleanor/raw 19 | version: 724aedf6e1a5d8971aafec384b6bde3d5608fba4 20 | repo: https://github.com/feyeleanor/raw 21 | - name: github.com/feyeleanor/sets 22 | version: 6c54cb57ea406ff6354256a4847e37298194478f 23 | repo: https://github.com/feyeleanor/sets 24 | - name: github.com/feyeleanor/slices 25 | version: bb44bb2e4817fe71ba7082d351fd582e7d40e3ea 26 | repo: https://github.com/feyeleanor/slices 27 | - name: github.com/godbus/dbus 28 | version: e4593d66e29678c26f84166fe231a03e0268ced5 29 | repo: https://github.com/godbus/dbus 30 | - name: gopkg.in/check.v1 31 | version: 4f90aeace3a26ad7021961c297b22c42160c7b25 32 | repo: https://gopkg.in/check.v1 33 | - name: gopkg.in/yaml.v1 34 | version: 9f9df34309c04878acc86042b16630b0f696e1de 35 | repo: https://gopkg.in/yaml.v1 36 | devImports: [] 37 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: . 2 | import: 3 | - package: github.com/coreos/pkg 4 | version: v2 5 | subpackages: 6 | - /flagutil 7 | - package: github.com/goamz/goamz 8 | version: 8b901b531db8fca1529b05bfa948605b01ca3ab0 9 | subpackages: 10 | - /aws 11 | -------------------------------------------------------------------------------- /vendor/github.com/bitly/go-simplejson/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.0.3 4 | - 1.1.2 5 | - 1.2 6 | - tip 7 | install: 8 | - go get github.com/bmizerany/assert 9 | notifications: 10 | email: false 11 | -------------------------------------------------------------------------------- /vendor/github.com/bitly/go-simplejson/LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /vendor/github.com/bitly/go-simplejson/README.md: -------------------------------------------------------------------------------- 1 | ### go-simplejson 2 | 3 | a Go package to interact with arbitrary JSON 4 | 5 | [![Build Status](https://secure.travis-ci.org/bitly/go-simplejson.png)](http://travis-ci.org/bitly/go-simplejson) 6 | 7 | ### Importing 8 | 9 | import github.com/bitly/go-simplejson 10 | 11 | ### Documentation 12 | 13 | Visit the docs on [gopkgdoc](http://godoc.org/github.com/bitly/go-simplejson) 14 | -------------------------------------------------------------------------------- /vendor/github.com/bitly/go-simplejson/simplejson_go10.go: -------------------------------------------------------------------------------- 1 | // +build !go1.1 2 | 3 | package simplejson 4 | 5 | import ( 6 | "encoding/json" 7 | "errors" 8 | "io" 9 | "reflect" 10 | ) 11 | 12 | // NewFromReader returns a *Json by decoding from an io.Reader 13 | func NewFromReader(r io.Reader) (*Json, error) { 14 | j := new(Json) 15 | dec := json.NewDecoder(r) 16 | err := dec.Decode(&j.data) 17 | return j, err 18 | } 19 | 20 | // Implements the json.Unmarshaler interface. 21 | func (j *Json) UnmarshalJSON(p []byte) error { 22 | return json.Unmarshal(p, &j.data) 23 | } 24 | 25 | // Float64 coerces into a float64 26 | func (j *Json) Float64() (float64, error) { 27 | switch j.data.(type) { 28 | case float32, float64: 29 | return reflect.ValueOf(j.data).Float(), nil 30 | case int, int8, int16, int32, int64: 31 | return float64(reflect.ValueOf(j.data).Int()), nil 32 | case uint, uint8, uint16, uint32, uint64: 33 | return float64(reflect.ValueOf(j.data).Uint()), nil 34 | } 35 | return 0, errors.New("invalid value type") 36 | } 37 | 38 | // Int coerces into an int 39 | func (j *Json) Int() (int, error) { 40 | switch j.data.(type) { 41 | case float32, float64: 42 | return int(reflect.ValueOf(j.data).Float()), nil 43 | case int, int8, int16, int32, int64: 44 | return int(reflect.ValueOf(j.data).Int()), nil 45 | case uint, uint8, uint16, uint32, uint64: 46 | return int(reflect.ValueOf(j.data).Uint()), nil 47 | } 48 | return 0, errors.New("invalid value type") 49 | } 50 | 51 | // Int64 coerces into an int64 52 | func (j *Json) Int64() (int64, error) { 53 | switch j.data.(type) { 54 | case float32, float64: 55 | return int64(reflect.ValueOf(j.data).Float()), nil 56 | case int, int8, int16, int32, int64: 57 | return reflect.ValueOf(j.data).Int(), nil 58 | case uint, uint8, uint16, uint32, uint64: 59 | return int64(reflect.ValueOf(j.data).Uint()), nil 60 | } 61 | return 0, errors.New("invalid value type") 62 | } 63 | 64 | // Uint64 coerces into an uint64 65 | func (j *Json) Uint64() (uint64, error) { 66 | switch j.data.(type) { 67 | case float32, float64: 68 | return uint64(reflect.ValueOf(j.data).Float()), nil 69 | case int, int8, int16, int32, int64: 70 | return uint64(reflect.ValueOf(j.data).Int()), nil 71 | case uint, uint8, uint16, uint32, uint64: 72 | return reflect.ValueOf(j.data).Uint(), nil 73 | } 74 | return 0, errors.New("invalid value type") 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/bitly/go-simplejson/simplejson_go10_test.go: -------------------------------------------------------------------------------- 1 | // +build !go1.1 2 | 3 | package simplejson 4 | 5 | import ( 6 | "bytes" 7 | "github.com/bmizerany/assert" 8 | "strconv" 9 | "testing" 10 | ) 11 | 12 | func TestNewFromReader(t *testing.T) { 13 | buf := bytes.NewBuffer([]byte(`{ 14 | "test": { 15 | "array": [1, "2", 3], 16 | "arraywithsubs": [ 17 | {"subkeyone": 1}, 18 | {"subkeytwo": 2, "subkeythree": 3} 19 | ], 20 | "bignum": 8000000000 21 | } 22 | }`)) 23 | js, err := NewFromReader(buf) 24 | 25 | //Standard Test Case 26 | assert.NotEqual(t, nil, js) 27 | assert.Equal(t, nil, err) 28 | 29 | arr, _ := js.Get("test").Get("array").Array() 30 | assert.NotEqual(t, nil, arr) 31 | for i, v := range arr { 32 | var iv int 33 | switch v.(type) { 34 | case float64: 35 | iv = int(v.(float64)) 36 | case string: 37 | iv, _ = strconv.Atoi(v.(string)) 38 | } 39 | assert.Equal(t, i+1, iv) 40 | } 41 | 42 | ma := js.Get("test").Get("array").MustArray() 43 | assert.Equal(t, ma, []interface{}{float64(1), "2", float64(3)}) 44 | 45 | mm := js.Get("test").Get("arraywithsubs").GetIndex(0).MustMap() 46 | assert.Equal(t, mm, map[string]interface{}{"subkeyone": float64(1)}) 47 | 48 | assert.Equal(t, js.Get("test").Get("bignum").MustInt64(), int64(8000000000)) 49 | } 50 | 51 | func TestSimplejsonGo10(t *testing.T) { 52 | js, err := NewJson([]byte(`{ 53 | "test": { 54 | "array": [1, "2", 3], 55 | "arraywithsubs": [ 56 | {"subkeyone": 1}, 57 | {"subkeytwo": 2, "subkeythree": 3} 58 | ], 59 | "bignum": 8000000000 60 | } 61 | }`)) 62 | 63 | assert.NotEqual(t, nil, js) 64 | assert.Equal(t, nil, err) 65 | 66 | arr, _ := js.Get("test").Get("array").Array() 67 | assert.NotEqual(t, nil, arr) 68 | for i, v := range arr { 69 | var iv int 70 | switch v.(type) { 71 | case float64: 72 | iv = int(v.(float64)) 73 | case string: 74 | iv, _ = strconv.Atoi(v.(string)) 75 | } 76 | assert.Equal(t, i+1, iv) 77 | } 78 | 79 | ma := js.Get("test").Get("array").MustArray() 80 | assert.Equal(t, ma, []interface{}{float64(1), "2", float64(3)}) 81 | 82 | mm := js.Get("test").Get("arraywithsubs").GetIndex(0).MustMap() 83 | assert.Equal(t, mm, map[string]interface{}{"subkeyone": float64(1)}) 84 | 85 | assert.Equal(t, js.Get("test").Get("bignum").MustInt64(), int64(8000000000)) 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.4 3 | 4 | install: 5 | - go get github.com/godbus/dbus 6 | 7 | script: 8 | - ./test 9 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/README.md: -------------------------------------------------------------------------------- 1 | # go-systemd 2 | 3 | [![Build Status](https://travis-ci.org/coreos/go-systemd.png?branch=master)](https://travis-ci.org/coreos/go-systemd) 4 | [![godoc](https://godoc.org/github.com/coreos/go-systemd?status.svg)](http://godoc.org/github.com/coreos/go-systemd) 5 | 6 | Go bindings to systemd. The project has several packages: 7 | 8 | - `activation` - for writing and using socket activation from Go 9 | - `dbus` - for starting/stopping/inspecting running services and units 10 | - `journal` - for writing to systemd's logging service, journald 11 | - `sdjournal` - for reading from journald by wrapping its C API 12 | - `machine1` - for registering machines/containers with systemd 13 | - `unit` - for (de)serialization and comparison of unit files 14 | 15 | ## Socket Activation 16 | 17 | An example HTTP server using socket activation can be quickly set up by following this README on a Linux machine running systemd: 18 | 19 | https://github.com/coreos/go-systemd/tree/master/examples/activation/httpserver 20 | 21 | ## Journal 22 | 23 | Using the pure-Go `journal` package you can submit journal entries directly to systemd's journal, taking advantage of features like indexed key/value pairs for each log entry. 24 | The `sdjournal` package provides read access to the journal by wrapping around journald's native C API; consequently it requires cgo and the journal headers to be available. 25 | 26 | ## D-Bus 27 | 28 | The `dbus` package connects to the [systemd D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/dbus/) and lets you start, stop and introspect systemd units. The API docs are here: 29 | 30 | http://godoc.org/github.com/coreos/go-systemd/dbus 31 | 32 | ### Debugging 33 | 34 | Create `/etc/dbus-1/system-local.conf` that looks like this: 35 | 36 | ``` 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ``` 47 | 48 | ## machined 49 | 50 | The `machine1` package allows interaction with the [systemd machined D-Bus API](http://www.freedesktop.org/wiki/Software/systemd/machined/). 51 | 52 | ## Units 53 | 54 | The `unit` package provides various functions for working with [systemd unit files](http://www.freedesktop.org/software/systemd/man/systemd.unit.html). 55 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/activation/files.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package activation implements primitives for systemd socket activation. 16 | package activation 17 | 18 | import ( 19 | "os" 20 | "strconv" 21 | "syscall" 22 | ) 23 | 24 | // based on: https://gist.github.com/alberts/4640792 25 | const ( 26 | listenFdsStart = 3 27 | ) 28 | 29 | func Files(unsetEnv bool) []*os.File { 30 | if unsetEnv { 31 | defer os.Unsetenv("LISTEN_PID") 32 | defer os.Unsetenv("LISTEN_FDS") 33 | } 34 | 35 | pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) 36 | if err != nil || pid != os.Getpid() { 37 | return nil 38 | } 39 | 40 | nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS")) 41 | if err != nil || nfds == 0 { 42 | return nil 43 | } 44 | 45 | files := make([]*os.File, 0, nfds) 46 | for fd := listenFdsStart; fd < listenFdsStart+nfds; fd++ { 47 | syscall.CloseOnExec(fd) 48 | files = append(files, os.NewFile(uintptr(fd), "LISTEN_FD_"+strconv.Itoa(fd))) 49 | } 50 | 51 | return files 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/activation/listeners.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package activation 16 | 17 | import ( 18 | "crypto/tls" 19 | "net" 20 | ) 21 | 22 | // Listeners returns a slice containing a net.Listener for each matching socket type 23 | // passed to this process. 24 | // 25 | // The order of the file descriptors is preserved in the returned slice. 26 | // Nil values are used to fill any gaps. For example if systemd were to return file descriptors 27 | // corresponding with "udp, tcp, tcp", then the slice would contain {nil, net.Listener, net.Listener} 28 | func Listeners(unsetEnv bool) ([]net.Listener, error) { 29 | files := Files(unsetEnv) 30 | listeners := make([]net.Listener, len(files)) 31 | 32 | for i, f := range files { 33 | if pc, err := net.FileListener(f); err == nil { 34 | listeners[i] = pc 35 | } 36 | } 37 | return listeners, nil 38 | } 39 | 40 | // TLSListeners returns a slice containing a net.listener for each matching TCP socket type 41 | // passed to this process. 42 | // It uses default Listeners func and forces TCP sockets handlers to use TLS based on tlsConfig. 43 | func TLSListeners(unsetEnv bool, tlsConfig *tls.Config) ([]net.Listener, error) { 44 | listeners, err := Listeners(unsetEnv) 45 | 46 | if listeners == nil || err != nil { 47 | return nil, err 48 | } 49 | 50 | if tlsConfig != nil && err == nil { 51 | tlsConfig.NextProtos = []string{"http/1.1"} 52 | 53 | for i, l := range listeners { 54 | // Activate TLS only for TCP sockets 55 | if l.Addr().Network() == "tcp" { 56 | listeners[i] = tls.NewListener(l, tlsConfig) 57 | } 58 | } 59 | } 60 | 61 | return listeners, err 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/activation/listeners_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package activation 16 | 17 | import ( 18 | "io" 19 | "net" 20 | "os" 21 | "os/exec" 22 | "testing" 23 | ) 24 | 25 | // correctStringWritten fails the text if the correct string wasn't written 26 | // to the other side of the pipe. 27 | func correctStringWrittenNet(t *testing.T, r net.Conn, expected string) bool { 28 | bytes := make([]byte, len(expected)) 29 | io.ReadAtLeast(r, bytes, len(expected)) 30 | 31 | if string(bytes) != expected { 32 | t.Fatalf("Unexpected string %s", string(bytes)) 33 | } 34 | 35 | return true 36 | } 37 | 38 | // TestActivation forks out a copy of activation.go example and reads back two 39 | // strings from the pipes that are passed in. 40 | func TestListeners(t *testing.T) { 41 | cmd := exec.Command("go", "run", "../examples/activation/listen.go") 42 | 43 | l1, err := net.Listen("tcp", ":9999") 44 | if err != nil { 45 | t.Fatalf(err.Error()) 46 | } 47 | l2, err := net.Listen("tcp", ":1234") 48 | if err != nil { 49 | t.Fatalf(err.Error()) 50 | } 51 | 52 | t1 := l1.(*net.TCPListener) 53 | t2 := l2.(*net.TCPListener) 54 | 55 | f1, _ := t1.File() 56 | f2, _ := t2.File() 57 | 58 | cmd.ExtraFiles = []*os.File{ 59 | f1, 60 | f2, 61 | } 62 | 63 | r1, err := net.Dial("tcp", "127.0.0.1:9999") 64 | if err != nil { 65 | t.Fatalf(err.Error()) 66 | } 67 | r1.Write([]byte("Hi")) 68 | 69 | r2, err := net.Dial("tcp", "127.0.0.1:1234") 70 | if err != nil { 71 | t.Fatalf(err.Error()) 72 | } 73 | r2.Write([]byte("Hi")) 74 | 75 | cmd.Env = os.Environ() 76 | cmd.Env = append(cmd.Env, "LISTEN_FDS=2", "FIX_LISTEN_PID=1") 77 | 78 | out, err := cmd.Output() 79 | if err != nil { 80 | println(string(out)) 81 | t.Fatalf(err.Error()) 82 | } 83 | 84 | correctStringWrittenNet(t, r1, "Hello world") 85 | correctStringWrittenNet(t, r2, "Goodbye world") 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/activation/packetconns.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package activation 16 | 17 | import ( 18 | "net" 19 | ) 20 | 21 | // PacketConns returns a slice containing a net.PacketConn for each matching socket type 22 | // passed to this process. 23 | // 24 | // The order of the file descriptors is preserved in the returned slice. 25 | // Nil values are used to fill any gaps. For example if systemd were to return file descriptors 26 | // corresponding with "udp, tcp, udp", then the slice would contain {net.PacketConn, nil, net.PacketConn} 27 | func PacketConns(unsetEnv bool) ([]net.PacketConn, error) { 28 | files := Files(unsetEnv) 29 | conns := make([]net.PacketConn, len(files)) 30 | 31 | for i, f := range files { 32 | if pc, err := net.FilePacketConn(f); err == nil { 33 | conns[i] = pc 34 | } 35 | } 36 | return conns, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/activation/packetconns_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package activation 16 | 17 | import ( 18 | "net" 19 | "os" 20 | "os/exec" 21 | "testing" 22 | ) 23 | 24 | // TestActivation forks out a copy of activation.go example and reads back two 25 | // strings from the pipes that are passed in. 26 | func TestPacketConns(t *testing.T) { 27 | cmd := exec.Command("go", "run", "../examples/activation/udpconn.go") 28 | 29 | u1, err := net.ListenUDP("udp", &net.UDPAddr{Port: 9999}) 30 | if err != nil { 31 | t.Fatalf(err.Error()) 32 | } 33 | u2, err := net.ListenUDP("udp", &net.UDPAddr{Port: 1234}) 34 | if err != nil { 35 | t.Fatalf(err.Error()) 36 | } 37 | 38 | f1, _ := u1.File() 39 | f2, _ := u2.File() 40 | 41 | cmd.ExtraFiles = []*os.File{ 42 | f1, 43 | f2, 44 | } 45 | 46 | r1, err := net.Dial("udp", "127.0.0.1:9999") 47 | if err != nil { 48 | t.Fatalf(err.Error()) 49 | } 50 | r1.Write([]byte("Hi")) 51 | 52 | r2, err := net.Dial("udp", "127.0.0.1:1234") 53 | if err != nil { 54 | t.Fatalf(err.Error()) 55 | } 56 | r2.Write([]byte("Hi")) 57 | 58 | cmd.Env = os.Environ() 59 | cmd.Env = append(cmd.Env, "LISTEN_FDS=2", "FIX_LISTEN_PID=1") 60 | 61 | out, err := cmd.CombinedOutput() 62 | if err != nil { 63 | t.Fatalf("Cmd output '%s', err: '%s'\n", out, err) 64 | } 65 | 66 | correctStringWrittenNet(t, r1, "Hello world") 67 | correctStringWrittenNet(t, r2, "Goodbye world") 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/daemon/sdnotify.go: -------------------------------------------------------------------------------- 1 | // Code forked from Docker project 2 | package daemon 3 | 4 | import ( 5 | "errors" 6 | "net" 7 | "os" 8 | ) 9 | 10 | var SdNotifyNoSocket = errors.New("No socket") 11 | 12 | // SdNotify sends a message to the init daemon. It is common to ignore the error. 13 | func SdNotify(state string) error { 14 | socketAddr := &net.UnixAddr{ 15 | Name: os.Getenv("NOTIFY_SOCKET"), 16 | Net: "unixgram", 17 | } 18 | 19 | if socketAddr.Name == "" { 20 | return SdNotifyNoSocket 21 | } 22 | 23 | conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr) 24 | if err != nil { 25 | return err 26 | } 27 | defer conn.Close() 28 | 29 | _, err = conn.Write([]byte(state)) 30 | return err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/dbus_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | func TestNeedsEscape(t *testing.T) { 22 | // Anything not 0-9a-zA-Z should always be escaped 23 | for want, vals := range map[bool][]byte{ 24 | false: []byte{'a', 'b', 'z', 'A', 'Q', '1', '4', '9'}, 25 | true: []byte{'#', '%', '$', '!', '.', '_', '-', '%', '\\'}, 26 | } { 27 | for i := 1; i < 10; i++ { 28 | for _, b := range vals { 29 | got := needsEscape(i, b) 30 | if got != want { 31 | t.Errorf("needsEscape(%d, %c) returned %t, want %t", i, b, got, want) 32 | } 33 | } 34 | } 35 | } 36 | 37 | // 0-9 in position 0 should be escaped 38 | for want, vals := range map[bool][]byte{ 39 | false: []byte{'A', 'a', 'e', 'x', 'Q', 'Z'}, 40 | true: []byte{'0', '4', '5', '9'}, 41 | } { 42 | for _, b := range vals { 43 | got := needsEscape(0, b) 44 | if got != want { 45 | t.Errorf("needsEscape(0, %c) returned %t, want %t", b, got, want) 46 | } 47 | } 48 | } 49 | 50 | } 51 | 52 | func TestPathBusEscape(t *testing.T) { 53 | for in, want := range map[string]string{ 54 | "": "_", 55 | "foo.service": "foo_2eservice", 56 | "foobar": "foobar", 57 | "woof@woof.service": "woof_40woof_2eservice", 58 | "0123456": "_30123456", 59 | "account_db.service": "account_5fdb_2eservice", 60 | "got-dashes": "got_2ddashes", 61 | } { 62 | got := PathBusEscape(in) 63 | if got != want { 64 | t.Errorf("bad result for PathBusEscape(%s): got %q, want %q", in, got, want) 65 | } 66 | } 67 | 68 | } 69 | 70 | // TestNew ensures that New() works without errors. 71 | func TestNew(t *testing.T) { 72 | _, err := New() 73 | 74 | if err != nil { 75 | t.Fatal(err) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | type set struct { 18 | data map[string]bool 19 | } 20 | 21 | func (s *set) Add(value string) { 22 | s.data[value] = true 23 | } 24 | 25 | func (s *set) Remove(value string) { 26 | delete(s.data, value) 27 | } 28 | 29 | func (s *set) Contains(value string) (exists bool) { 30 | _, exists = s.data[value] 31 | return 32 | } 33 | 34 | func (s *set) Length() int { 35 | return len(s.data) 36 | } 37 | 38 | func (s *set) Values() (values []string) { 39 | for val, _ := range s.data { 40 | values = append(values, val) 41 | } 42 | return 43 | } 44 | 45 | func newSet() *set { 46 | return &set{make(map[string]bool)} 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/set_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | // TestBasicSetActions asserts that Add & Remove behavior is correct 22 | func TestBasicSetActions(t *testing.T) { 23 | s := newSet() 24 | 25 | if s.Contains("foo") { 26 | t.Fatal("set should not contain 'foo'") 27 | } 28 | 29 | s.Add("foo") 30 | 31 | if !s.Contains("foo") { 32 | t.Fatal("set should contain 'foo'") 33 | } 34 | 35 | v := s.Values() 36 | if len(v) != 1 { 37 | t.Fatal("set.Values did not report correct number of values") 38 | } 39 | if v[0] != "foo" { 40 | t.Fatal("set.Values did not report value") 41 | } 42 | 43 | s.Remove("foo") 44 | 45 | if s.Contains("foo") { 46 | t.Fatal("set should not contain 'foo'") 47 | } 48 | 49 | v = s.Values() 50 | if len(v) != 0 { 51 | t.Fatal("set.Values did not report correct number of values") 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/subscription_set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | // SubscriptionSet returns a subscription set which is like conn.Subscribe but 22 | // can filter to only return events for a set of units. 23 | type SubscriptionSet struct { 24 | *set 25 | conn *Conn 26 | } 27 | 28 | func (s *SubscriptionSet) filter(unit string) bool { 29 | return !s.Contains(unit) 30 | } 31 | 32 | // Subscribe starts listening for dbus events for all of the units in the set. 33 | // Returns channels identical to conn.SubscribeUnits. 34 | func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { 35 | // TODO: Make fully evented by using systemd 209 with properties changed values 36 | return s.conn.SubscribeUnitsCustom(time.Second, 0, 37 | mismatchUnitStatus, 38 | func(unit string) bool { return s.filter(unit) }, 39 | ) 40 | } 41 | 42 | // NewSubscriptionSet returns a new subscription set. 43 | func (conn *Conn) NewSubscriptionSet() *SubscriptionSet { 44 | return &SubscriptionSet{newSet(), conn} 45 | } 46 | 47 | // mismatchUnitStatus returns true if the provided UnitStatus objects 48 | // are not equivalent. false is returned if the objects are equivalent. 49 | // Only the Name, Description and state-related fields are used in 50 | // the comparison. 51 | func mismatchUnitStatus(u1, u2 *UnitStatus) bool { 52 | return u1.Name != u2.Name || 53 | u1.Description != u2.Description || 54 | u1.LoadState != u2.LoadState || 55 | u1.ActiveState != u2.ActiveState || 56 | u1.SubState != u2.SubState 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dbus 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | ) 21 | 22 | // TestSubscribeUnit exercises the basics of subscription of a particular unit. 23 | func TestSubscriptionSetUnit(t *testing.T) { 24 | target := "subscribe-events-set.service" 25 | 26 | conn, err := New() 27 | 28 | if err != nil { 29 | t.Fatal(err) 30 | } 31 | 32 | err = conn.Subscribe() 33 | if err != nil { 34 | t.Fatal(err) 35 | } 36 | 37 | subSet := conn.NewSubscriptionSet() 38 | evChan, errChan := subSet.Subscribe() 39 | 40 | subSet.Add(target) 41 | setupUnit(target, conn, t) 42 | linkUnit(target, conn, t) 43 | 44 | reschan := make(chan string) 45 | _, err = conn.StartUnit(target, "replace", reschan) 46 | if err != nil { 47 | t.Fatal(err) 48 | } 49 | 50 | job := <-reschan 51 | if job != "done" { 52 | t.Fatal("Couldn't start", target) 53 | } 54 | 55 | timeout := make(chan bool, 1) 56 | go func() { 57 | time.Sleep(3 * time.Second) 58 | close(timeout) 59 | }() 60 | 61 | for { 62 | select { 63 | case changes := <-evChan: 64 | tCh, ok := changes[target] 65 | 66 | if !ok { 67 | t.Fatal("Unexpected event:", changes) 68 | } 69 | 70 | if tCh.ActiveState == "active" && tCh.Name == target { 71 | goto success 72 | } 73 | case err = <-errChan: 74 | t.Fatal(err) 75 | case <-timeout: 76 | t.Fatal("Reached timeout") 77 | } 78 | } 79 | 80 | success: 81 | return 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/activation.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Activation example used by the activation unit tests. 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "os" 21 | 22 | "github.com/coreos/go-systemd/activation" 23 | ) 24 | 25 | func fixListenPid() { 26 | if os.Getenv("FIX_LISTEN_PID") != "" { 27 | // HACK: real systemd would set LISTEN_PID before exec'ing but 28 | // this is too difficult in golang for the purpose of a test. 29 | // Do not do this in real code. 30 | os.Setenv("LISTEN_PID", fmt.Sprintf("%d", os.Getpid())) 31 | } 32 | } 33 | 34 | func main() { 35 | fixListenPid() 36 | 37 | files := activation.Files(false) 38 | 39 | if len(files) == 0 { 40 | panic("No files") 41 | } 42 | 43 | if os.Getenv("LISTEN_PID") == "" || os.Getenv("LISTEN_FDS") == "" { 44 | panic("Should not unset envs") 45 | } 46 | 47 | files = activation.Files(true) 48 | 49 | if os.Getenv("LISTEN_PID") != "" || os.Getenv("LISTEN_FDS") != "" { 50 | panic("Can not unset envs") 51 | } 52 | 53 | // Write out the expected strings to the two pipes 54 | files[0].Write([]byte("Hello world")) 55 | files[1].Write([]byte("Goodbye world")) 56 | 57 | return 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/httpserver/README.md: -------------------------------------------------------------------------------- 1 | ## socket activated http server 2 | 3 | This is a simple example of using socket activation with systemd to serve a 4 | simple HTTP server on http://127.0.0.1:8076 5 | 6 | To try it out `go get` the httpserver and run it under the systemd-activate helper 7 | 8 | ``` 9 | export GOPATH=`pwd` 10 | go get github.com/coreos/go-systemd/examples/activation/httpserver 11 | sudo /usr/lib/systemd/systemd-activate -l 127.0.0.1:8076 ./bin/httpserver 12 | ``` 13 | 14 | Then curl the URL and you will notice that it starts up: 15 | 16 | ``` 17 | curl 127.0.0.1:8076 18 | hello socket activated world! 19 | ``` 20 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/httpserver/hello.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hello World HTTP 3 | Requires=network.target 4 | After=multi-user.target 5 | 6 | [Service] 7 | Type=simple 8 | ExecStart=/usr/local/bin/httpserver 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/httpserver/hello.socket: -------------------------------------------------------------------------------- 1 | [Socket] 2 | ListenStream=127.0.0.1:8076 3 | 4 | [Install] 5 | WantedBy=sockets.target 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/httpserver/httpserver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "io" 19 | "net/http" 20 | 21 | "github.com/coreos/go-systemd/activation" 22 | ) 23 | 24 | func HelloServer(w http.ResponseWriter, req *http.Request) { 25 | io.WriteString(w, "hello socket activated world!\n") 26 | } 27 | 28 | func main() { 29 | listeners, err := activation.Listeners(true) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | if len(listeners) != 1 { 35 | panic("Unexpected number of socket activation fds") 36 | } 37 | 38 | http.HandleFunc("/", HelloServer) 39 | http.Serve(listeners[0], nil) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/listen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Activation example used by the activation unit tests. 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "os" 21 | 22 | "github.com/coreos/go-systemd/activation" 23 | ) 24 | 25 | func fixListenPid() { 26 | if os.Getenv("FIX_LISTEN_PID") != "" { 27 | // HACK: real systemd would set LISTEN_PID before exec'ing but 28 | // this is too difficult in golang for the purpose of a test. 29 | // Do not do this in real code. 30 | os.Setenv("LISTEN_PID", fmt.Sprintf("%d", os.Getpid())) 31 | } 32 | } 33 | 34 | func main() { 35 | fixListenPid() 36 | 37 | listeners, _ := activation.Listeners(false) 38 | 39 | if len(listeners) == 0 { 40 | panic("No listeners") 41 | } 42 | 43 | if os.Getenv("LISTEN_PID") == "" || os.Getenv("LISTEN_FDS") == "" { 44 | panic("Should not unset envs") 45 | } 46 | 47 | listeners, err := activation.Listeners(true) 48 | if err != nil { 49 | panic(err) 50 | } 51 | 52 | if os.Getenv("LISTEN_PID") != "" || os.Getenv("LISTEN_FDS") != "" { 53 | panic("Can not unset envs") 54 | } 55 | 56 | c0, _ := listeners[0].Accept() 57 | c1, _ := listeners[1].Accept() 58 | 59 | // Write out the expected strings to the two pipes 60 | c0.Write([]byte("Hello world")) 61 | c1.Write([]byte("Goodbye world")) 62 | 63 | return 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/examples/activation/udpconn.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Activation example used by the activation unit tests. 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "net" 21 | "os" 22 | 23 | "github.com/coreos/go-systemd/activation" 24 | ) 25 | 26 | func fixListenPid() { 27 | if os.Getenv("FIX_LISTEN_PID") != "" { 28 | // HACK: real systemd would set LISTEN_PID before exec'ing but 29 | // this is too difficult in golang for the purpose of a test. 30 | // Do not do this in real code. 31 | os.Setenv("LISTEN_PID", fmt.Sprintf("%d", os.Getpid())) 32 | } 33 | } 34 | 35 | func main() { 36 | fixListenPid() 37 | 38 | pc, _ := activation.PacketConns(false) 39 | 40 | if len(pc) == 0 { 41 | panic("No packetConns") 42 | } 43 | 44 | if os.Getenv("LISTEN_PID") == "" || os.Getenv("LISTEN_FDS") == "" { 45 | panic("Should not unset envs") 46 | } 47 | 48 | pc, err := activation.PacketConns(true) 49 | if err != nil { 50 | panic(err) 51 | } 52 | 53 | if os.Getenv("LISTEN_PID") != "" || os.Getenv("LISTEN_FDS") != "" { 54 | panic("Can not unset envs") 55 | } 56 | 57 | udp1, ok := pc[0].(*net.UDPConn) 58 | if !ok { 59 | panic("packetConn 1 not UDP") 60 | } 61 | udp2, ok := pc[1].(*net.UDPConn) 62 | if !ok { 63 | panic("packetConn 2 not UDP") 64 | } 65 | 66 | _, addr1, err := udp1.ReadFromUDP(nil) 67 | if err != nil { 68 | panic(err) 69 | } 70 | _, addr2, err := udp2.ReadFromUDP(nil) 71 | if err != nil { 72 | panic(err) 73 | } 74 | 75 | // Write out the expected strings to the two pipes 76 | _, err = udp1.WriteToUDP([]byte("Hello world"), addr1) 77 | if err != nil { 78 | panic(err) 79 | } 80 | _, err = udp2.WriteToUDP([]byte("Goodbye world"), addr2) 81 | if err != nil { 82 | panic(err) 83 | } 84 | 85 | return 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/fixtures/enable-disable.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=enable disable test 3 | 4 | [Service] 5 | ExecStart=/bin/sleep 400 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/fixtures/start-stop.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=start stop test 3 | 4 | [Service] 5 | ExecStart=/bin/sleep 400 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/fixtures/subscribe-events-set.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=start stop test 3 | 4 | [Service] 5 | ExecStart=/bin/sleep 400 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/fixtures/subscribe-events.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=start stop test 3 | 4 | [Service] 5 | ExecStart=/bin/sleep 400 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/login1/dbus_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package login1 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | // TestNew ensures that New() works without errors. 22 | func TestNew(t *testing.T) { 23 | _, err := New() 24 | 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/machine1/dbus.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Integration with the systemd machined API. See http://www.freedesktop.org/wiki/Software/systemd/machined/ 18 | package machine1 19 | 20 | import ( 21 | "os" 22 | "strconv" 23 | 24 | "github.com/godbus/dbus" 25 | ) 26 | 27 | const ( 28 | dbusInterface = "org.freedesktop.machine1.Manager" 29 | dbusPath = "/org/freedesktop/machine1" 30 | ) 31 | 32 | // Conn is a connection to systemds dbus endpoint. 33 | type Conn struct { 34 | conn *dbus.Conn 35 | object dbus.BusObject 36 | } 37 | 38 | // New() establishes a connection to the system bus and authenticates. 39 | func New() (*Conn, error) { 40 | c := new(Conn) 41 | 42 | if err := c.initConnection(); err != nil { 43 | return nil, err 44 | } 45 | 46 | return c, nil 47 | } 48 | 49 | func (c *Conn) initConnection() error { 50 | var err error 51 | c.conn, err = dbus.SystemBusPrivate() 52 | if err != nil { 53 | return err 54 | } 55 | 56 | // Only use EXTERNAL method, and hardcode the uid (not username) 57 | // to avoid a username lookup (which requires a dynamically linked 58 | // libc) 59 | methods := []dbus.Auth{dbus.AuthExternal(strconv.Itoa(os.Getuid()))} 60 | 61 | err = c.conn.Auth(methods) 62 | if err != nil { 63 | c.conn.Close() 64 | return err 65 | } 66 | 67 | err = c.conn.Hello() 68 | if err != nil { 69 | c.conn.Close() 70 | return err 71 | } 72 | 73 | c.object = c.conn.Object("org.freedesktop.machine1", dbus.ObjectPath(dbusPath)) 74 | 75 | return nil 76 | } 77 | 78 | // RegisterMachine registers the container with the systemd-machined 79 | func (c *Conn) RegisterMachine(name string, id []byte, service string, class string, pid int, root_directory string) error { 80 | return c.object.Call(dbusInterface+".RegisterMachine", 0, name, id, service, class, uint32(pid), root_directory).Err 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/machine1/dbus_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package machine1 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | // TestNew ensures that New() works without errors. 24 | func TestNew(t *testing.T) { 25 | _, err := New() 26 | 27 | if err != nil { 28 | t.Fatal(err) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/sdjournal/journal_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 RedHat, Inc. 2 | // Copyright 2015 CoreOS, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package sdjournal 17 | 18 | import ( 19 | "os" 20 | "testing" 21 | "time" 22 | 23 | "github.com/coreos/go-systemd/journal" 24 | ) 25 | 26 | func TestJournalFollow(t *testing.T) { 27 | r, err := NewJournalReader(JournalReaderConfig{ 28 | Since: time.Duration(-15) * time.Second, 29 | Matches: []Match{ 30 | { 31 | Field: SD_JOURNAL_FIELD_SYSTEMD_UNIT, 32 | Value: "NetworkManager.service", 33 | }, 34 | }, 35 | }) 36 | 37 | if err != nil { 38 | t.Fatalf("Error opening journal: %s", err) 39 | } 40 | 41 | if r == nil { 42 | t.Fatal("Got a nil reader") 43 | } 44 | 45 | defer r.Close() 46 | 47 | // start writing some test entries 48 | done := make(chan struct{}, 1) 49 | defer close(done) 50 | go func() { 51 | for { 52 | select { 53 | case <-done: 54 | return 55 | default: 56 | if err = journal.Print(journal.PriInfo, "test message %s", time.Now()); err != nil { 57 | t.Fatalf("Error writing to journal: %s", err) 58 | } 59 | 60 | time.Sleep(time.Second) 61 | } 62 | } 63 | }() 64 | 65 | // and follow the reader synchronously 66 | timeout := time.Duration(5) * time.Second 67 | if err = r.Follow(time.After(timeout), os.Stdout); err != ErrExpired { 68 | t.Fatalf("Error during follow: %s", err) 69 | } 70 | } 71 | 72 | func TestJournalGetUsage(t *testing.T) { 73 | j, err := NewJournal() 74 | 75 | if err != nil { 76 | t.Fatalf("Error opening journal: %s", err) 77 | } 78 | 79 | if j == nil { 80 | t.Fatal("Got a nil journal") 81 | } 82 | 83 | defer j.Close() 84 | 85 | _, err = j.GetUsage() 86 | 87 | if err != nil { 88 | t.Fatalf("Error getting journal size: %s", err) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Run all tests 4 | # ./test 5 | # ./test -v 6 | # 7 | # Run tests for one package 8 | # PKG=./foo ./test 9 | # PKG=bar ./test 10 | # 11 | 12 | # Invoke ./cover for HTML output 13 | COVER=${COVER:-"-cover"} 14 | 15 | PROJ="go-systemd" 16 | ORG_PATH="github.com/coreos" 17 | REPO_PATH="${ORG_PATH}/${PROJ}" 18 | 19 | # As a convenience, set up a self-contained GOPATH if none set 20 | if [ -z "$GOPATH" ]; then 21 | if [ ! -h gopath/src/${REPO_PATH} ]; then 22 | mkdir -p gopath/src/${ORG_PATH} 23 | ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 24 | fi 25 | export GOPATH=${PWD}/gopath 26 | go get -u github.com/godbus/dbus 27 | fi 28 | 29 | TESTABLE="activation journal login1 machine1 unit" 30 | FORMATTABLE="$TESTABLE sdjournal dbus" 31 | if [ -e "/run/systemd/system/" ]; then 32 | TESTABLE="${TESTABLE} sdjournal" 33 | if [ "$EUID" == "0" ]; then 34 | # testing actual systemd behaviour requires root 35 | TESTABLE="${TESTABLE} dbus" 36 | fi 37 | fi 38 | 39 | 40 | # user has not provided PKG override 41 | if [ -z "$PKG" ]; then 42 | TEST=$TESTABLE 43 | FMT=$FORMATTABLE 44 | 45 | # user has provided PKG override 46 | else 47 | # strip out slashes and dots from PKG=./foo/ 48 | TEST=${PKG//\//} 49 | TEST=${TEST//./} 50 | 51 | # only run gofmt on packages provided by user 52 | FMT="$TEST" 53 | fi 54 | 55 | # split TEST into an array and prepend REPO_PATH to each local package 56 | split=(${TEST// / }) 57 | TEST=${split[@]/#/${REPO_PATH}/} 58 | 59 | echo "Running tests..." 60 | go test ${COVER} $@ ${TEST} 61 | 62 | echo "Checking gofmt..." 63 | fmtRes=$(gofmt -l $FMT) 64 | if [ -n "${fmtRes}" ]; then 65 | echo -e "gofmt checking failed:\n${fmtRes}" 66 | exit 255 67 | fi 68 | 69 | echo "Checking govet..." 70 | vetRes=$(go vet $TEST) 71 | if [ -n "${vetRes}" ]; then 72 | echo -e "govet checking failed:\n${vetRes}" 73 | exit 255 74 | fi 75 | 76 | echo "Success" 77 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/unit/end_to_end_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "bytes" 19 | "io/ioutil" 20 | "testing" 21 | ) 22 | 23 | func TestDeserializeAndReserialize(t *testing.T) { 24 | tests := []struct { 25 | in string 26 | wout string 27 | }{ 28 | { 29 | `[Service] 30 | ExecStart=/bin/bash -c "while true; do echo \"ping\"; sleep 1; done" 31 | `, 32 | `[Service] 33 | ExecStart=/bin/bash -c "while true; do echo \"ping\"; sleep 1; done" 34 | `}, 35 | { 36 | `[Unit] 37 | Description= Unnecessarily wrapped \ 38 | words here`, 39 | `[Unit] 40 | Description=Unnecessarily wrapped \ 41 | words here 42 | `, 43 | }, 44 | { 45 | `[Unit] 46 | Description=Demo \ 47 | 48 | Requires=docker.service 49 | `, 50 | `[Unit] 51 | Description=Demo \ 52 | 53 | Requires=docker.service 54 | `, 55 | }, 56 | { 57 | `; comment alpha 58 | # comment bravo 59 | [Unit] 60 | ; comment charlie 61 | # comment delta 62 | #Description=Foo 63 | Description=Bar 64 | ; comment echo 65 | # comment foxtrot 66 | `, 67 | `[Unit] 68 | Description=Bar 69 | `}, 70 | } 71 | for i, tt := range tests { 72 | ds, err := Deserialize(bytes.NewBufferString(tt.in)) 73 | if err != nil { 74 | t.Errorf("case %d: unexpected error parsing unit: %v", i, err) 75 | continue 76 | } 77 | out, err := ioutil.ReadAll(Serialize(ds)) 78 | if err != nil { 79 | t.Errorf("case %d: unexpected error serializing unit: %v", i, err) 80 | continue 81 | } 82 | if g := string(out); g != tt.wout { 83 | t.Errorf("case %d: incorrect output", i) 84 | t.Logf("Expected:\n%#v", tt.wout) 85 | t.Logf("Actual:\n%#v", g) 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/unit/option.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | type UnitOption struct { 22 | Section string 23 | Name string 24 | Value string 25 | } 26 | 27 | func NewUnitOption(section, name, value string) *UnitOption { 28 | return &UnitOption{Section: section, Name: name, Value: value} 29 | } 30 | 31 | func (uo *UnitOption) String() string { 32 | return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value) 33 | } 34 | 35 | func (uo *UnitOption) Match(other *UnitOption) bool { 36 | return uo.Section == other.Section && 37 | uo.Name == other.Name && 38 | uo.Value == other.Value 39 | } 40 | 41 | func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool { 42 | length := len(u1) 43 | if length != len(u2) { 44 | return false 45 | } 46 | 47 | for i := 0; i < length; i++ { 48 | if !u1[i].Match(u2[i]) { 49 | return false 50 | } 51 | } 52 | 53 | return true 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/go-systemd/unit/serialize.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "bytes" 19 | "io" 20 | ) 21 | 22 | // Serialize encodes all of the given UnitOption objects into a 23 | // unit file. When serialized the options are sorted in their 24 | // supplied order but grouped by section. 25 | func Serialize(opts []*UnitOption) io.Reader { 26 | var buf bytes.Buffer 27 | 28 | if len(opts) == 0 { 29 | return &buf 30 | } 31 | 32 | // Index of sections -> ordered options 33 | idx := map[string][]*UnitOption{} 34 | // Separately preserve order in which sections were seen 35 | sections := []string{} 36 | for _, opt := range opts { 37 | sec := opt.Section 38 | if _, ok := idx[sec]; !ok { 39 | sections = append(sections, sec) 40 | } 41 | idx[sec] = append(idx[sec], opt) 42 | } 43 | 44 | for i, sect := range sections { 45 | writeSectionHeader(&buf, sect) 46 | writeNewline(&buf) 47 | 48 | opts := idx[sect] 49 | for _, opt := range opts { 50 | writeOption(&buf, opt) 51 | writeNewline(&buf) 52 | } 53 | if i < len(sections)-1 { 54 | writeNewline(&buf) 55 | } 56 | } 57 | 58 | return &buf 59 | } 60 | 61 | func writeNewline(buf *bytes.Buffer) { 62 | buf.WriteRune('\n') 63 | } 64 | 65 | func writeSectionHeader(buf *bytes.Buffer, section string) { 66 | buf.WriteRune('[') 67 | buf.WriteString(section) 68 | buf.WriteRune(']') 69 | } 70 | 71 | func writeOption(buf *bytes.Buffer, opt *UnitOption) { 72 | buf.WriteString(opt.Name) 73 | buf.WriteRune('=') 74 | buf.WriteString(opt.Value) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | bin/ 27 | coverage/ 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Ed Rooth (@sym3tri) 2 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/README.md: -------------------------------------------------------------------------------- 1 | a collection of go utility packages 2 | 3 | [![Build Status](https://semaphoreci.com/api/v1/projects/14b3f261-22c2-4f56-b1ff-f23f4aa03f5c/411991/badge.svg)](https://semaphoreci.com/coreos/pkg) [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/coreos/pkg) 4 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | go build ./... 4 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/example/hello_dolly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "flag" 19 | oldlog "log" 20 | 21 | "github.com/coreos/pkg/capnslog" 22 | ) 23 | 24 | var logLevel = capnslog.INFO 25 | var log = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "main") 26 | var dlog = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "dolly") 27 | 28 | func init() { 29 | flag.Var(&logLevel, "log-level", "Global log level.") 30 | } 31 | 32 | func main() { 33 | rl := capnslog.MustRepoLogger("github.com/coreos/pkg/capnslog/cmd") 34 | 35 | // We can parse the log level configs from the command line 36 | flag.Parse() 37 | if flag.NArg() > 1 { 38 | cfg, err := rl.ParseLogLevelConfig(flag.Arg(1)) 39 | if err != nil { 40 | log.Fatal(err) 41 | } 42 | rl.SetLogLevel(cfg) 43 | log.Infof("Setting output to %s", flag.Arg(1)) 44 | } 45 | 46 | // Send some messages at different levels to the different packages 47 | dlog.Infof("Hello Dolly") 48 | dlog.Warningf("Well hello, Dolly") 49 | log.Errorf("It's so nice to have you back where you belong") 50 | dlog.Debugf("You're looking swell, Dolly") 51 | dlog.Tracef("I can tell, Dolly") 52 | 53 | // We also have control over the built-in "log" package. 54 | capnslog.SetGlobalLogLevel(logLevel) 55 | oldlog.Println("You're still glowin', you're still crowin', you're still lookin' strong") 56 | log.Fatalf("Dolly'll never go away again") 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // +build !windows 16 | 17 | package capnslog 18 | 19 | import ( 20 | "io" 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | // Here's where the opinionation comes in. We need some sensible defaults, 26 | // especially after taking over the log package. Your project (whatever it may 27 | // be) may see things differently. That's okay; there should be no defaults in 28 | // the main package that cannot be controlled or overridden programatically, 29 | // otherwise it's a bug. Doing so is creating your own init_log.go file much 30 | // like this one. 31 | 32 | func init() { 33 | initHijack() 34 | 35 | // Go `log` pacakge uses os.Stderr. 36 | SetFormatter(NewDefaultFormatter(os.Stderr)) 37 | SetGlobalLogLevel(INFO) 38 | } 39 | 40 | func NewDefaultFormatter(out io.Writer) Formatter { 41 | if syscall.Getppid() == 1 { 42 | // We're running under init, which may be systemd. 43 | f, err := NewJournaldFormatter() 44 | if err == nil { 45 | return f 46 | } 47 | } 48 | return NewPrettyFormatter(out, false) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/init_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package capnslog 16 | 17 | import "os" 18 | 19 | func init() { 20 | initHijack() 21 | 22 | // Go `log` package uses os.Stderr. 23 | SetFormatter(NewPrettyFormatter(os.Stderr, false)) 24 | SetGlobalLogLevel(INFO) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/journald_formatter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // +build !windows 16 | 17 | package capnslog 18 | 19 | import ( 20 | "errors" 21 | "fmt" 22 | "os" 23 | "path/filepath" 24 | 25 | "github.com/coreos/go-systemd/journal" 26 | ) 27 | 28 | func NewJournaldFormatter() (Formatter, error) { 29 | if !journal.Enabled() { 30 | return nil, errors.New("No systemd detected") 31 | } 32 | return &journaldFormatter{}, nil 33 | } 34 | 35 | type journaldFormatter struct{} 36 | 37 | func (j *journaldFormatter) Format(pkg string, l LogLevel, _ int, entries ...interface{}) { 38 | var pri journal.Priority 39 | switch l { 40 | case CRITICAL: 41 | pri = journal.PriCrit 42 | case ERROR: 43 | pri = journal.PriErr 44 | case WARNING: 45 | pri = journal.PriWarning 46 | case NOTICE: 47 | pri = journal.PriNotice 48 | case INFO: 49 | pri = journal.PriInfo 50 | case DEBUG: 51 | pri = journal.PriDebug 52 | case TRACE: 53 | pri = journal.PriDebug 54 | default: 55 | panic("Unhandled loglevel") 56 | } 57 | msg := fmt.Sprint(entries...) 58 | tags := map[string]string{ 59 | "PACKAGE": pkg, 60 | "SYSLOG_IDENTIFIER": filepath.Base(os.Args[0]), 61 | } 62 | err := journal.Send(msg, pri, tags) 63 | if err != nil { 64 | fmt.Fprintln(os.Stderr, err) 65 | } 66 | } 67 | 68 | func (j *journaldFormatter) Flush() {} 69 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/log_hijack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package capnslog 16 | 17 | import ( 18 | "log" 19 | ) 20 | 21 | func initHijack() { 22 | pkg := NewPackageLogger("log", "") 23 | w := packageWriter{pkg} 24 | log.SetFlags(0) 25 | log.SetPrefix("") 26 | log.SetOutput(w) 27 | } 28 | 29 | type packageWriter struct { 30 | pl *PackageLogger 31 | } 32 | 33 | func (p packageWriter) Write(b []byte) (int, error) { 34 | if p.pl.level < INFO { 35 | return 0, nil 36 | } 37 | p.pl.internalLog(calldepth+2, INFO, string(b)) 38 | return len(b), nil 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/syslog_formatter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // +build !windows 16 | 17 | package capnslog 18 | 19 | import ( 20 | "fmt" 21 | "log/syslog" 22 | ) 23 | 24 | func NewSyslogFormatter(w *syslog.Writer) Formatter { 25 | return &syslogFormatter{w} 26 | } 27 | 28 | func NewDefaultSyslogFormatter(tag string) (Formatter, error) { 29 | w, err := syslog.New(syslog.LOG_DEBUG, tag) 30 | if err != nil { 31 | return nil, err 32 | } 33 | return NewSyslogFormatter(w), nil 34 | } 35 | 36 | type syslogFormatter struct { 37 | w *syslog.Writer 38 | } 39 | 40 | func (s *syslogFormatter) Format(pkg string, l LogLevel, _ int, entries ...interface{}) { 41 | for _, entry := range entries { 42 | str := fmt.Sprint(entry) 43 | switch l { 44 | case CRITICAL: 45 | s.w.Crit(str) 46 | case ERROR: 47 | s.w.Err(str) 48 | case WARNING: 49 | s.w.Warning(str) 50 | case NOTICE: 51 | s.w.Notice(str) 52 | case INFO: 53 | s.w.Info(str) 54 | case DEBUG: 55 | s.w.Debug(str) 56 | case TRACE: 57 | s.w.Debug(str) 58 | default: 59 | panic("Unhandled loglevel") 60 | } 61 | } 62 | } 63 | 64 | func (s *syslogFormatter) Flush() { 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/flagutil/env.go: -------------------------------------------------------------------------------- 1 | package flagutil 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // SetFlagsFromEnv parses all registered flags in the given flagset, 11 | // and if they are not already set it attempts to set their values from 12 | // environment variables. Environment variables take the name of the flag but 13 | // are UPPERCASE, and any dashes are replaced by underscores. Environment 14 | // variables additionally are prefixed by the given string followed by 15 | // and underscore. For example, if prefix=PREFIX: some-flag => PREFIX_SOME_FLAG 16 | func SetFlagsFromEnv(fs *flag.FlagSet, prefix string) (err error) { 17 | alreadySet := make(map[string]bool) 18 | fs.Visit(func(f *flag.Flag) { 19 | alreadySet[f.Name] = true 20 | }) 21 | fs.VisitAll(func(f *flag.Flag) { 22 | if !alreadySet[f.Name] { 23 | key := prefix + "_" + strings.ToUpper(strings.Replace(f.Name, "-", "_", -1)) 24 | val := os.Getenv(key) 25 | if val != "" { 26 | if serr := fs.Set(f.Name, val); serr != nil { 27 | err = fmt.Errorf("invalid value %q for %s: %v", val, key, serr) 28 | } 29 | } 30 | } 31 | }) 32 | return err 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/flagutil/env_test.go: -------------------------------------------------------------------------------- 1 | package flagutil 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | func TestSetFlagsFromEnv(t *testing.T) { 10 | fs := flag.NewFlagSet("testing", flag.ExitOnError) 11 | fs.String("a", "", "") 12 | fs.String("b", "", "") 13 | fs.String("c", "", "") 14 | fs.Parse([]string{}) 15 | 16 | os.Clearenv() 17 | // flags should be settable using env vars 18 | os.Setenv("MYPROJ_A", "foo") 19 | // and command-line flags 20 | if err := fs.Set("b", "bar"); err != nil { 21 | t.Fatal(err) 22 | } 23 | // command-line flags take precedence over env vars 24 | os.Setenv("MYPROJ_C", "woof") 25 | if err := fs.Set("c", "quack"); err != nil { 26 | t.Fatal(err) 27 | } 28 | 29 | // first verify that flags are as expected before reading the env 30 | for f, want := range map[string]string{ 31 | "a": "", 32 | "b": "bar", 33 | "c": "quack", 34 | } { 35 | if got := fs.Lookup(f).Value.String(); got != want { 36 | t.Fatalf("flag %q=%q, want %q", f, got, want) 37 | } 38 | } 39 | 40 | // now read the env and verify flags were updated as expected 41 | err := SetFlagsFromEnv(fs, "MYPROJ") 42 | if err != nil { 43 | t.Errorf("err=%v, want nil", err) 44 | } 45 | for f, want := range map[string]string{ 46 | "a": "foo", 47 | "b": "bar", 48 | "c": "quack", 49 | } { 50 | if got := fs.Lookup(f).Value.String(); got != want { 51 | t.Errorf("flag %q=%q, want %q", f, got, want) 52 | } 53 | } 54 | } 55 | 56 | func TestSetFlagsFromEnvBad(t *testing.T) { 57 | // now verify that an error is propagated 58 | fs := flag.NewFlagSet("testing", flag.ExitOnError) 59 | fs.Int("x", 0, "") 60 | os.Setenv("MYPROJ_X", "not_a_number") 61 | if err := SetFlagsFromEnv(fs, "MYPROJ"); err == nil { 62 | t.Errorf("err=nil, want != nil") 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/flagutil/types.go: -------------------------------------------------------------------------------- 1 | package flagutil 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net" 7 | "strings" 8 | ) 9 | 10 | // IPv4Flag parses a string into a net.IP after asserting that it 11 | // is an IPv4 address. This type implements the flag.Value interface. 12 | type IPv4Flag struct { 13 | val net.IP 14 | } 15 | 16 | func (f *IPv4Flag) IP() net.IP { 17 | return f.val 18 | } 19 | 20 | func (f *IPv4Flag) Set(v string) error { 21 | ip := net.ParseIP(v) 22 | if ip == nil || ip.To4() == nil { 23 | return errors.New("not an IPv4 address") 24 | } 25 | f.val = ip 26 | return nil 27 | } 28 | 29 | func (f *IPv4Flag) String() string { 30 | return f.val.String() 31 | } 32 | 33 | // StringSliceFlag parses a comma-delimited list of strings into 34 | // a []string. This type implements the flag.Value interface. 35 | type StringSliceFlag []string 36 | 37 | func (ss *StringSliceFlag) String() string { 38 | return fmt.Sprintf("%+v", *ss) 39 | } 40 | 41 | func (ss *StringSliceFlag) Set(v string) error { 42 | *ss = strings.Split(v, ",") 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/flagutil/types_test.go: -------------------------------------------------------------------------------- 1 | package flagutil 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestIPv4FlagSetInvalidArgument(t *testing.T) { 9 | tests := []string{ 10 | "", 11 | "foo", 12 | "::", 13 | "127.0.0.1:4328", 14 | } 15 | 16 | for i, tt := range tests { 17 | var f IPv4Flag 18 | if err := f.Set(tt); err == nil { 19 | t.Errorf("case %d: expected non-nil error", i) 20 | } 21 | } 22 | } 23 | 24 | func TestIPv4FlagSetValidArgument(t *testing.T) { 25 | tests := []string{ 26 | "127.0.0.1", 27 | "0.0.0.0", 28 | } 29 | 30 | for i, tt := range tests { 31 | var f IPv4Flag 32 | if err := f.Set(tt); err != nil { 33 | t.Errorf("case %d: err=%v", i, err) 34 | } 35 | } 36 | } 37 | 38 | func TestStringSliceFlag(t *testing.T) { 39 | tests := []struct { 40 | input string 41 | want []string 42 | }{ 43 | {input: "", want: []string{""}}, 44 | {input: "foo", want: []string{"foo"}}, 45 | {input: "foo,bar", want: []string{"foo", "bar"}}, 46 | } 47 | 48 | for i, tt := range tests { 49 | var f StringSliceFlag 50 | if err := f.Set(tt.input); err != nil { 51 | t.Errorf("case %d: err=%v", i, err) 52 | } 53 | if !reflect.DeepEqual(tt.want, []string(f)) { 54 | t.Errorf("case %d: want=%v got=%v", i, tt.want, f) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/health/README.md: -------------------------------------------------------------------------------- 1 | health 2 | ==== 3 | 4 | A simple framework for implementing an HTTP health check endpoint on servers. 5 | 6 | Users implement their `health.Checkable` types, and create a `health.Checker`, from which they can get an `http.HandlerFunc` using `health.Checker.MakeHealthHandlerFunc`. 7 | 8 | ### Documentation 9 | 10 | For more details, visit the docs on [gopkgdoc](http://godoc.org/github.com/coreos/pkg/health) 11 | 12 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/httputil/README.md: -------------------------------------------------------------------------------- 1 | httputil 2 | ==== 3 | 4 | Common code for dealing with HTTP. 5 | 6 | Includes: 7 | 8 | * Code for returning JSON responses. 9 | 10 | ### Documentation 11 | 12 | Visit the docs on [gopkgdoc](http://godoc.org/github.com/coreos/pkg/httputil) 13 | 14 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/httputil/cookie.go: -------------------------------------------------------------------------------- 1 | package httputil 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | ) 7 | 8 | // DeleteCookies effectively deletes all named cookies 9 | // by wiping all data and setting to expire immediately. 10 | func DeleteCookies(w http.ResponseWriter, cookieNames ...string) { 11 | for _, n := range cookieNames { 12 | c := &http.Cookie{ 13 | Name: n, 14 | Value: "", 15 | Path: "/", 16 | MaxAge: -1, 17 | Expires: time.Time{}, 18 | } 19 | http.SetCookie(w, c) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/httputil/cookie_test.go: -------------------------------------------------------------------------------- 1 | package httputil 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestDeleteCookies(t *testing.T) { 11 | tests := []struct { 12 | // cookie names to delete 13 | n []string 14 | }{ 15 | // single 16 | { 17 | n: []string{"foo"}, 18 | }, 19 | // multiple 20 | { 21 | n: []string{"foo", "bar"}, 22 | }, 23 | } 24 | 25 | for i, tt := range tests { 26 | w := httptest.NewRecorder() 27 | DeleteCookies(w, tt.n...) 28 | resp := &http.Response{} 29 | resp.Header = w.Header() 30 | cks := resp.Cookies() 31 | 32 | if len(cks) != len(tt.n) { 33 | t.Errorf("case %d: unexpected number of cookies, want: %d, got: %d", i, len(tt.n), len(cks)) 34 | } 35 | 36 | for _, c := range cks { 37 | if c.Value != "" { 38 | t.Errorf("case %d: unexpected cookie value, want: %q, got: %q", i, "", c.Value) 39 | } 40 | if c.Path != "/" { 41 | t.Errorf("case %d: unexpected cookie path, want: %q, got: %q", i, "/", c.Path) 42 | } 43 | if c.MaxAge != -1 { 44 | t.Errorf("case %d: unexpected cookie max-age, want: %q, got: %q", i, -1, c.MaxAge) 45 | } 46 | if !c.Expires.IsZero() { 47 | t.Errorf("case %d: unexpected cookie expires, want: %q, got: %q", i, time.Time{}, c.MaxAge) 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/httputil/json.go: -------------------------------------------------------------------------------- 1 | package httputil 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | ) 7 | 8 | const ( 9 | JSONContentType = "application/json" 10 | ) 11 | 12 | func WriteJSONResponse(w http.ResponseWriter, code int, resp interface{}) error { 13 | enc, err := json.Marshal(resp) 14 | if err != nil { 15 | w.WriteHeader(http.StatusInternalServerError) 16 | return err 17 | } 18 | 19 | w.Header().Set("Content-Type", JSONContentType) 20 | w.WriteHeader(code) 21 | 22 | _, err = w.Write(enc) 23 | if err != nil { 24 | return err 25 | } 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/httputil/json_test.go: -------------------------------------------------------------------------------- 1 | package httputil 2 | 3 | import ( 4 | "net/http/httptest" 5 | "testing" 6 | ) 7 | 8 | func TestWriteJSONResponse(t *testing.T) { 9 | for i, test := range []struct { 10 | code int 11 | resp interface{} 12 | expectedJSON string 13 | expectErr bool 14 | }{ 15 | { 16 | 200, 17 | struct { 18 | A string 19 | B string 20 | }{A: "foo", B: "bar"}, 21 | `{"A":"foo","B":"bar"}`, 22 | false, 23 | }, 24 | { 25 | 500, 26 | // Something that json.Marshal cannot serialize. 27 | make(chan int), 28 | "", 29 | true, 30 | }, 31 | } { 32 | w := httptest.NewRecorder() 33 | err := WriteJSONResponse(w, test.code, test.resp) 34 | 35 | if w.Code != test.code { 36 | t.Errorf("case %d: w.code == %v, want %v", i, w.Code, test.code) 37 | } 38 | 39 | if (err != nil) != test.expectErr { 40 | t.Errorf("case %d: (err != nil) == %v, want %v. err: %v", i, err != nil, test.expectErr, err) 41 | } 42 | 43 | if string(w.Body.Bytes()) != test.expectedJSON { 44 | t.Errorf("case %d: w.Body.Bytes()) == %q, want %q", i, 45 | string(w.Body.Bytes()), test.expectedJSON) 46 | } 47 | 48 | if !test.expectErr { 49 | contentType := w.Header()["Content-Type"][0] 50 | if contentType != JSONContentType { 51 | t.Errorf("case %d: contentType == %v, want %v", i, contentType, JSONContentType) 52 | } 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/multierror/multierror.go: -------------------------------------------------------------------------------- 1 | // Package multierror wraps a slice of errors and implements the error interface. 2 | // This can be used to collect a bunch of errors (such as during form validation) 3 | // and then return them all together as a single error. To see usage examples 4 | // refer to the unit tests. 5 | package multierror 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | type Error []error 13 | 14 | func (me Error) Error() string { 15 | if me == nil { 16 | return "" 17 | } 18 | 19 | strs := make([]string, len(me)) 20 | for i, err := range me { 21 | strs[i] = fmt.Sprintf("[%d] %v", i, err) 22 | } 23 | return strings.Join(strs, " ") 24 | } 25 | 26 | func (me Error) AsError() error { 27 | if len([]error(me)) <= 0 { 28 | return nil 29 | } 30 | 31 | return me 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/multierror/multierror_test.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | import ( 4 | "errors" 5 | "reflect" 6 | "testing" 7 | ) 8 | 9 | func TestAsError(t *testing.T) { 10 | tests := []struct { 11 | multierr Error 12 | want error 13 | }{ 14 | { 15 | multierr: Error([]error{errors.New("foo"), errors.New("bar")}), 16 | want: Error([]error{errors.New("foo"), errors.New("bar")}), 17 | }, 18 | { 19 | multierr: Error([]error{}), 20 | want: nil, 21 | }, 22 | { 23 | multierr: Error(nil), 24 | want: nil, 25 | }, 26 | } 27 | 28 | for i, tt := range tests { 29 | got := tt.multierr.AsError() 30 | if !reflect.DeepEqual(tt.want, got) { 31 | t.Errorf("case %d: incorrect error value: want=%+v got=%+v", i, tt.want, got) 32 | } 33 | } 34 | 35 | } 36 | 37 | func TestErrorAppend(t *testing.T) { 38 | var multierr Error 39 | multierr = append(multierr, errors.New("foo")) 40 | multierr = append(multierr, errors.New("bar")) 41 | multierr = append(multierr, errors.New("baz")) 42 | want := Error([]error{errors.New("foo"), errors.New("bar"), errors.New("baz")}) 43 | got := multierr.AsError() 44 | if !reflect.DeepEqual(want, got) { 45 | t.Fatalf("incorrect error value: want=%+v got=%+v", want, got) 46 | } 47 | } 48 | 49 | func TestErrorString(t *testing.T) { 50 | var multierr Error 51 | multierr = append(multierr, errors.New("foo")) 52 | multierr = append(multierr, errors.New("bar")) 53 | multierr = append(multierr, errors.New("baz")) 54 | got := multierr.Error() 55 | want := "[0] foo [1] bar [2] baz" 56 | if want != got { 57 | t.Fatalf("incorrect output: want=%q got=%q", want, got) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/netutil/proxy.go: -------------------------------------------------------------------------------- 1 | package netutil 2 | 3 | import ( 4 | "io" 5 | "net" 6 | "sync" 7 | "time" 8 | 9 | "github.com/coreos/pkg/capnslog" 10 | ) 11 | 12 | var ( 13 | log = capnslog.NewPackageLogger("github.com/coreos/pkg/netutil", "main") 14 | ) 15 | 16 | // ProxyTCP proxies between two TCP connections. 17 | // Because TLS connections don't have CloseRead() and CloseWrite() methods, our 18 | // temporary solution is to use timeouts. 19 | func ProxyTCP(conn1, conn2 net.Conn, tlsWriteDeadline, tlsReadDeadline time.Duration) { 20 | var wg sync.WaitGroup 21 | wg.Add(2) 22 | 23 | go copyBytes(conn1, conn2, &wg, tlsWriteDeadline, tlsReadDeadline) 24 | go copyBytes(conn2, conn1, &wg, tlsWriteDeadline, tlsReadDeadline) 25 | 26 | wg.Wait() 27 | conn1.Close() 28 | conn2.Close() 29 | } 30 | 31 | func copyBytes(dst, src net.Conn, wg *sync.WaitGroup, writeDeadline, readDeadline time.Duration) { 32 | defer wg.Done() 33 | n, err := io.Copy(dst, src) 34 | if err != nil { 35 | log.Errorf("proxy i/o error: %v", err) 36 | } 37 | 38 | if cr, ok := src.(*net.TCPConn); ok { 39 | cr.CloseRead() 40 | } else { 41 | // For TLS connections. 42 | wto := time.Now().Add(writeDeadline) 43 | src.SetWriteDeadline(wto) 44 | } 45 | 46 | if cw, ok := dst.(*net.TCPConn); ok { 47 | cw.CloseWrite() 48 | } else { 49 | // For TLS connections. 50 | rto := time.Now().Add(readDeadline) 51 | dst.SetReadDeadline(rto) 52 | } 53 | 54 | log.Debugf("proxy copied %d bytes %s -> %s", n, src.RemoteAddr(), dst.RemoteAddr()) 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/netutil/url.go: -------------------------------------------------------------------------------- 1 | package netutil 2 | 3 | import ( 4 | "net/url" 5 | ) 6 | 7 | // MergeQuery appends additional query values to an existing URL. 8 | func MergeQuery(u url.URL, q url.Values) url.URL { 9 | uv := u.Query() 10 | for k, vs := range q { 11 | for _, v := range vs { 12 | uv.Add(k, v) 13 | } 14 | } 15 | u.RawQuery = uv.Encode() 16 | return u 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/netutil/url_test.go: -------------------------------------------------------------------------------- 1 | package netutil 2 | 3 | import ( 4 | "net/url" 5 | "reflect" 6 | "testing" 7 | ) 8 | 9 | func TestMergeQuery(t *testing.T) { 10 | tests := []struct { 11 | u string 12 | q url.Values 13 | w string 14 | }{ 15 | // No values 16 | { 17 | u: "http://example.com", 18 | q: nil, 19 | w: "http://example.com", 20 | }, 21 | // No additional values 22 | { 23 | u: "http://example.com?foo=bar", 24 | q: nil, 25 | w: "http://example.com?foo=bar", 26 | }, 27 | // Simple addition 28 | { 29 | u: "http://example.com", 30 | q: url.Values{ 31 | "foo": []string{"bar"}, 32 | }, 33 | w: "http://example.com?foo=bar", 34 | }, 35 | // Addition with existing values 36 | { 37 | u: "http://example.com?dog=boo", 38 | q: url.Values{ 39 | "foo": []string{"bar"}, 40 | }, 41 | w: "http://example.com?dog=boo&foo=bar", 42 | }, 43 | // Merge 44 | { 45 | u: "http://example.com?dog=boo", 46 | q: url.Values{ 47 | "dog": []string{"elroy"}, 48 | }, 49 | w: "http://example.com?dog=boo&dog=elroy", 50 | }, 51 | // Add and merge 52 | { 53 | u: "http://example.com?dog=boo", 54 | q: url.Values{ 55 | "dog": []string{"elroy"}, 56 | "foo": []string{"bar"}, 57 | }, 58 | w: "http://example.com?dog=boo&dog=elroy&foo=bar", 59 | }, 60 | // Multivalue merge 61 | { 62 | u: "http://example.com?dog=boo", 63 | q: url.Values{ 64 | "dog": []string{"elroy", "penny"}, 65 | }, 66 | w: "http://example.com?dog=boo&dog=elroy&dog=penny", 67 | }, 68 | } 69 | 70 | for i, tt := range tests { 71 | ur, err := url.Parse(tt.u) 72 | if err != nil { 73 | t.Errorf("case %d: failed parsing test url: %v, error: %v", i, tt.u, err) 74 | } 75 | 76 | got := MergeQuery(*ur, tt.q) 77 | want, err := url.Parse(tt.w) 78 | if err != nil { 79 | t.Errorf("case %d: failed parsing want url: %v, error: %v", i, tt.w, err) 80 | } 81 | 82 | if !reflect.DeepEqual(*want, got) { 83 | t.Errorf("case %d: want: %v, got: %v", i, *want, got) 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Run all tests (not including functional) 4 | # ./test 5 | # ./test -v 6 | # 7 | # Run tests for one package 8 | # PKG=./unit ./test 9 | # PKG=ssh ./test 10 | # 11 | 12 | # Invoke ./cover for HTML output 13 | COVER=${COVER:-"-cover"} 14 | 15 | source ./build 16 | 17 | TESTABLE="cryptoutil flagutil timeutil netutil yamlutil httputil health multierror" 18 | FORMATTABLE="$TESTABLE capnslog" 19 | 20 | # user has not provided PKG override 21 | if [ -z "$PKG" ]; then 22 | TEST=$TESTABLE 23 | FMT=$FORMATTABLE 24 | 25 | # user has provided PKG override 26 | else 27 | # strip out slashes and dots from PKG=./foo/ 28 | TEST=${PKG//\//} 29 | TEST=${TEST//./} 30 | 31 | # only run gofmt on packages provided by user 32 | FMT="$TEST" 33 | fi 34 | 35 | # split TEST into an array and prepend repo path to each local package 36 | split=(${TEST// / }) 37 | TEST=${split[@]/#/github.com/coreos/pkg/} 38 | 39 | echo "Running tests..." 40 | go test ${COVER} $@ ${TEST} 41 | 42 | echo "Checking gofmt..." 43 | fmtRes=$(gofmt -l $FMT) 44 | if [ -n "${fmtRes}" ]; then 45 | echo -e "gofmt checking failed:\n${fmtRes}" 46 | exit 255 47 | fi 48 | 49 | echo "Checking govet..." 50 | vetRes=$(go vet $TEST) 51 | if [ -n "${vetRes}" ]; then 52 | echo -e "govet checking failed:\n${vetRes}" 53 | exit 255 54 | fi 55 | 56 | echo "Success" 57 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/timeutil/backoff.go: -------------------------------------------------------------------------------- 1 | package timeutil 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func ExpBackoff(prev, max time.Duration) time.Duration { 8 | if prev == 0 { 9 | return time.Second 10 | } 11 | if prev > max/2 { 12 | return max 13 | } 14 | return 2 * prev 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/timeutil/backoff_test.go: -------------------------------------------------------------------------------- 1 | package timeutil 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestExpBackoff(t *testing.T) { 9 | tests := []struct { 10 | prev time.Duration 11 | max time.Duration 12 | want time.Duration 13 | }{ 14 | { 15 | prev: time.Duration(0), 16 | max: time.Minute, 17 | want: time.Second, 18 | }, 19 | { 20 | prev: time.Second, 21 | max: time.Minute, 22 | want: 2 * time.Second, 23 | }, 24 | { 25 | prev: 16 * time.Second, 26 | max: time.Minute, 27 | want: 32 * time.Second, 28 | }, 29 | { 30 | prev: 32 * time.Second, 31 | max: time.Minute, 32 | want: time.Minute, 33 | }, 34 | { 35 | prev: time.Minute, 36 | max: time.Minute, 37 | want: time.Minute, 38 | }, 39 | { 40 | prev: 2 * time.Minute, 41 | max: time.Minute, 42 | want: time.Minute, 43 | }, 44 | } 45 | 46 | for i, tt := range tests { 47 | got := ExpBackoff(tt.prev, tt.max) 48 | if tt.want != got { 49 | t.Errorf("case %d: want=%v got=%v", i, tt.want, got) 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/yamlutil/yaml.go: -------------------------------------------------------------------------------- 1 | package yamlutil 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "strings" 7 | 8 | "gopkg.in/yaml.v1" 9 | ) 10 | 11 | // SetFlagsFromYaml goes through all registered flags in the given flagset, 12 | // and if they are not already set it attempts to set their values from 13 | // the YAML config. It will use the key REPLACE(UPPERCASE(flagname), '-', '_') 14 | func SetFlagsFromYaml(fs *flag.FlagSet, rawYaml []byte) (err error) { 15 | conf := make(map[string]string) 16 | if err = yaml.Unmarshal(rawYaml, conf); err != nil { 17 | return 18 | } 19 | alreadySet := map[string]struct{}{} 20 | fs.Visit(func(f *flag.Flag) { 21 | alreadySet[f.Name] = struct{}{} 22 | }) 23 | 24 | errs := make([]error, 0) 25 | fs.VisitAll(func(f *flag.Flag) { 26 | if f.Name == "" { 27 | return 28 | } 29 | if _, ok := alreadySet[f.Name]; ok { 30 | return 31 | } 32 | tag := strings.Replace(strings.ToUpper(f.Name), "-", "_", -1) 33 | val, ok := conf[tag] 34 | if !ok { 35 | return 36 | } 37 | if serr := fs.Set(f.Name, val); serr != nil { 38 | errs = append(errs, fmt.Errorf("invalid value %q for %s: %v", val, tag, serr)) 39 | } 40 | }) 41 | if len(errs) != 0 { 42 | err = ErrorSlice(errs) 43 | } 44 | return 45 | } 46 | 47 | type ErrorSlice []error 48 | 49 | func (e ErrorSlice) Error() string { 50 | s := "" 51 | for _, err := range e { 52 | s += ", " + err.Error() 53 | } 54 | return "Errors: " + s 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/yamlutil/yaml_test.go: -------------------------------------------------------------------------------- 1 | package yamlutil 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | ) 7 | 8 | func TestSetFlagsFromYaml(t *testing.T) { 9 | config := "A: foo\nC: woof" 10 | fs := flag.NewFlagSet("testing", flag.ExitOnError) 11 | fs.String("a", "", "") 12 | fs.String("b", "", "") 13 | fs.String("c", "", "") 14 | fs.Parse([]string{}) 15 | 16 | // flags should be settable using yaml vars 17 | // and command-line flags 18 | if err := fs.Set("b", "bar"); err != nil { 19 | t.Fatal(err) 20 | } 21 | // command-line flags take precedence over the file 22 | if err := fs.Set("c", "quack"); err != nil { 23 | t.Fatal(err) 24 | } 25 | 26 | // first verify that flags are as expected before reading the file 27 | for f, want := range map[string]string{ 28 | "a": "", 29 | "b": "bar", 30 | "c": "quack", 31 | } { 32 | if got := fs.Lookup(f).Value.String(); got != want { 33 | t.Fatalf("flag %q=%q, want %q", f, got, want) 34 | } 35 | } 36 | 37 | // now read the yaml and verify flags were updated as expected 38 | err := SetFlagsFromYaml(fs, []byte(config)) 39 | if err != nil { 40 | t.Errorf("err=%v, want nil", err) 41 | } 42 | for f, want := range map[string]string{ 43 | "a": "foo", 44 | "b": "bar", 45 | "c": "quack", 46 | } { 47 | if got := fs.Lookup(f).Value.String(); got != want { 48 | t.Errorf("flag %q=%q, want %q", f, got, want) 49 | } 50 | } 51 | } 52 | 53 | func TestSetFlagsFromYamlBad(t *testing.T) { 54 | // now verify that an error is propagated 55 | fs := flag.NewFlagSet("testing", flag.ExitOnError) 56 | fs.Int("x", 0, "") 57 | badConf := "X: not_a_number" 58 | if err := SetFlagsFromYaml(fs, []byte(badConf)); err == nil { 59 | t.Errorf("got err=nil, flag x=%q, want err != nil", fs.Lookup("x").Value.String()) 60 | } 61 | } 62 | 63 | func TestSetFlagsFromYamlMultiError(t *testing.T) { 64 | fs := flag.NewFlagSet("testing", flag.ExitOnError) 65 | fs.Int("x", 0, "") 66 | fs.Int("y", 0, "") 67 | fs.Int("z", 0, "") 68 | conf := "X: foo\nY: bar\nZ: 3" 69 | err := SetFlagsFromYaml(fs, []byte(conf)) 70 | if err == nil { 71 | t.Errorf("got err= nil, want err != nil") 72 | } 73 | es, ok := err.(ErrorSlice) 74 | if !ok { 75 | t.Errorf("Got ok=false want ok=true") 76 | } 77 | if len(es) != 2 { 78 | t.Errorf("2 errors should be contained in the error, got %d errors", len(es)) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.iml 3 | *.idea 4 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/.lbox: -------------------------------------------------------------------------------- 1 | propose -for=lp:goamz -cr 2 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.2 5 | - 1.3 6 | - 1.3.3 7 | - 1.4 8 | 9 | after_script: 10 | - FIXIT=$(go fmt ./...); if [ -n "${FIXIT}" ]; then FIXED=$(echo $FIXIT | wc -l); echo "gofmt - ${FIXED} file(s) not formatted correctly, please run gofmt to fix them:\n ${FIXIT} " && exit 1; fi 11 | 12 | script: 13 | - go test -v ./autoscaling/ 14 | - go test -v ./aws/ 15 | - go test -v ./cloudfront/ 16 | - go test -v ./cloudwatch/ 17 | - go test -v ./dynamodb/ 18 | - go test -v ./ec2/ 19 | - go test -v ./elasticache/ 20 | - go test -v ./elb/ 21 | - go test -v ./iam/ 22 | - go test -v ./kinesis/ 23 | - go test -v ./rds/ 24 | - go test -v ./s3/ 25 | - go test -v ./sns/ 26 | - go test -v ./sqs/ 27 | - go test -v ./sts/ 28 | - go test -v ./exp/mturk/ 29 | - go test -v ./exp/sdb/ 30 | - go test -v ./exp/ses/ 31 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/README.md: -------------------------------------------------------------------------------- 1 | # NO LONGER MAINTAINED, PLEASE GO TO https://github.com/AdRoll/goamz 2 | 3 | Long version: CrowdMob got kinda-sorta-acquihired by AdRoll. So we've simply moved the repo! 4 | See you on https://github.com/AdRoll/goamz 5 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | TODO 4 | ==== 5 | 6 | here will go things that we are activly pursuing. 7 | 8 | 9 | Brain Storm 10 | =========== 11 | 12 | This is an unsorted, list of things that are 'nice to do'. From this list we will move things up to the active TODO list. Please feel absolutely free to contribute. 13 | 14 | 1. Investigate if we can install `localdynamodb` on the ci to run tests against it. This way we can run behavioral tests that test the actual behavior. And keep them up to date with updates of `localdynamodb`. 15 | 16 | 2. Graduate items in `/exp` 17 | 18 | 3. Discusse "two tiered api". Basically the idea is to have a 'low level' api that is one to one match of the AWS http api, and a `higher level` api that abstracts away the details and is as go idiomatic as possible hiding away hairy details. 19 | 20 | 4. Find contributors with experience with each submodule (aws service), and review and plan for new refactored and cleaned up api. 21 | 22 | 5. It will be very helpfull to have better docs, sample code, best practices (for some people, goamz is their first exposure to AWS, and having a few essential tips on credentials and IAM roles and the like is very helpful). 23 | 24 | 6. If you've given any talks, presentation on goamz please let us know. We'd love to feature your video, slides, website here. 25 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/autoscaling/sign.go: -------------------------------------------------------------------------------- 1 | package autoscaling 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha256" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | "sort" 9 | "strings" 10 | ) 11 | 12 | // ---------------------------------------------------------------------------- 13 | // AutoScaling signing (http://goo.gl/fQmAN) 14 | 15 | var b64 = base64.StdEncoding 16 | 17 | func sign(auth aws.Auth, method, path string, params map[string]string, host string) { 18 | params["AWSAccessKeyId"] = auth.AccessKey 19 | params["SignatureVersion"] = "2" 20 | params["SignatureMethod"] = "HmacSHA256" 21 | if auth.Token() != "" { 22 | params["SecurityToken"] = auth.Token() 23 | } 24 | 25 | // AWS specifies that the parameters in a signed request must 26 | // be provided in the natural order of the keys. This is distinct 27 | // from the natural order of the encoded value of key=value. 28 | // Percent and gocheck.Equals affect the sorting order. 29 | var keys, sarray []string 30 | for k, _ := range params { 31 | keys = append(keys, k) 32 | } 33 | sort.Strings(keys) 34 | for _, k := range keys { 35 | sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(params[k])) 36 | } 37 | // Check whether path has any length and if not set it to / 38 | if len(path) == 0 { 39 | path = "/" 40 | } 41 | joined := strings.Join(sarray, "&") 42 | payload := method + "\n" + host + "\n" + path + "\n" + joined 43 | hash := hmac.New(sha256.New, []byte(auth.SecretKey)) 44 | hash.Write([]byte(payload)) 45 | signature := make([]byte, b64.EncodedLen(hash.Size())) 46 | b64.Encode(signature, hash.Sum(nil)) 47 | 48 | params["Signature"] = string(signature) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/aws/attempt.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // AttemptStrategy represents a strategy for waiting for an action 8 | // to complete successfully. This is an internal type used by the 9 | // implementation of other goamz packages. 10 | type AttemptStrategy struct { 11 | Total time.Duration // total duration of attempt. 12 | Delay time.Duration // interval between each try in the burst. 13 | Min int // minimum number of retries; overrides Total 14 | } 15 | 16 | type Attempt struct { 17 | strategy AttemptStrategy 18 | last time.Time 19 | end time.Time 20 | force bool 21 | count int 22 | } 23 | 24 | // Start begins a new sequence of attempts for the given strategy. 25 | func (s AttemptStrategy) Start() *Attempt { 26 | now := time.Now() 27 | return &Attempt{ 28 | strategy: s, 29 | last: now, 30 | end: now.Add(s.Total), 31 | force: true, 32 | } 33 | } 34 | 35 | // Next waits until it is time to perform the next attempt or returns 36 | // false if it is time to stop trying. 37 | func (a *Attempt) Next() bool { 38 | now := time.Now() 39 | sleep := a.nextSleep(now) 40 | if !a.force && !now.Add(sleep).Before(a.end) && a.strategy.Min <= a.count { 41 | return false 42 | } 43 | a.force = false 44 | if sleep > 0 && a.count > 0 { 45 | time.Sleep(sleep) 46 | now = time.Now() 47 | } 48 | a.count++ 49 | a.last = now 50 | return true 51 | } 52 | 53 | func (a *Attempt) nextSleep(now time.Time) time.Duration { 54 | sleep := a.strategy.Delay - now.Sub(a.last) 55 | if sleep < 0 { 56 | return 0 57 | } 58 | return sleep 59 | } 60 | 61 | // HasNext returns whether another attempt will be made if the current 62 | // one fails. If it returns true, the following call to Next is 63 | // guaranteed to return true. 64 | func (a *Attempt) HasNext() bool { 65 | if a.force || a.strategy.Min > a.count { 66 | return true 67 | } 68 | now := time.Now() 69 | if now.Add(a.nextSleep(now)).Before(a.end) { 70 | a.force = true 71 | return true 72 | } 73 | return false 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/aws/attempt_test.go: -------------------------------------------------------------------------------- 1 | package aws_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "gopkg.in/check.v1" 6 | "time" 7 | ) 8 | 9 | func (S) TestAttemptTiming(c *check.C) { 10 | testAttempt := aws.AttemptStrategy{ 11 | Total: 0.25e9, 12 | Delay: 0.1e9, 13 | } 14 | want := []time.Duration{0, 0.1e9, 0.2e9, 0.2e9} 15 | got := make([]time.Duration, 0, len(want)) // avoid allocation when testing timing 16 | t0 := time.Now() 17 | for a := testAttempt.Start(); a.Next(); { 18 | got = append(got, time.Now().Sub(t0)) 19 | } 20 | got = append(got, time.Now().Sub(t0)) 21 | c.Assert(got, check.HasLen, len(want)) 22 | const margin = 0.01e9 23 | for i, got := range want { 24 | lo := want[i] - margin 25 | hi := want[i] + margin 26 | if got < lo || got > hi { 27 | c.Errorf("attempt %d want %g got %g", i, want[i].Seconds(), got.Seconds()) 28 | } 29 | } 30 | } 31 | 32 | func (S) TestAttemptNextHasNext(c *check.C) { 33 | a := aws.AttemptStrategy{}.Start() 34 | c.Assert(a.Next(), check.Equals, true) 35 | c.Assert(a.Next(), check.Equals, false) 36 | 37 | a = aws.AttemptStrategy{}.Start() 38 | c.Assert(a.Next(), check.Equals, true) 39 | c.Assert(a.HasNext(), check.Equals, false) 40 | c.Assert(a.Next(), check.Equals, false) 41 | 42 | a = aws.AttemptStrategy{Total: 2e8}.Start() 43 | c.Assert(a.Next(), check.Equals, true) 44 | c.Assert(a.HasNext(), check.Equals, true) 45 | time.Sleep(2e8) 46 | c.Assert(a.HasNext(), check.Equals, true) 47 | c.Assert(a.Next(), check.Equals, true) 48 | c.Assert(a.Next(), check.Equals, false) 49 | 50 | a = aws.AttemptStrategy{Total: 1e8, Min: 2}.Start() 51 | time.Sleep(1e8) 52 | c.Assert(a.Next(), check.Equals, true) 53 | c.Assert(a.HasNext(), check.Equals, true) 54 | c.Assert(a.Next(), check.Equals, true) 55 | c.Assert(a.HasNext(), check.Equals, false) 56 | c.Assert(a.Next(), check.Equals, false) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/aws/export_test.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | ) 7 | 8 | // V4Signer: 9 | // Exporting methods for testing 10 | 11 | func (s *V4Signer) RequestTime(req *http.Request) time.Time { 12 | return s.requestTime(req) 13 | } 14 | 15 | func (s *V4Signer) CanonicalRequest(req *http.Request) string { 16 | return s.canonicalRequest(req, "") 17 | } 18 | 19 | func (s *V4Signer) StringToSign(t time.Time, creq string) string { 20 | return s.stringToSign(t, creq) 21 | } 22 | 23 | func (s *V4Signer) Signature(t time.Time, sts string) string { 24 | return s.signature(t, sts) 25 | } 26 | 27 | func (s *V4Signer) Authorization(header http.Header, t time.Time, signature string) string { 28 | return s.authorization(header, t, signature) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/cloudfront/cloudfront_test.go: -------------------------------------------------------------------------------- 1 | package cloudfront 2 | 3 | import ( 4 | "crypto/x509" 5 | "encoding/pem" 6 | "io/ioutil" 7 | "net/url" 8 | "testing" 9 | "time" 10 | ) 11 | 12 | func TestSignedCannedURL(t *testing.T) { 13 | rawKey, err := ioutil.ReadFile("testdata/key.pem") 14 | if err != nil { 15 | t.Fatal(err) 16 | } 17 | 18 | pemKey, _ := pem.Decode(rawKey) 19 | privateKey, err := x509.ParsePKCS1PrivateKey(pemKey.Bytes) 20 | if err != nil { 21 | t.Fatal(err) 22 | } 23 | 24 | cf := &CloudFront{ 25 | key: privateKey, 26 | keyPairId: "test-key-pair-1231245", 27 | BaseURL: "https://cloudfront.com", 28 | } 29 | 30 | expireTime, err := time.Parse(time.RFC3339, "2014-03-28T14:00:21Z") 31 | if err != nil { 32 | t.Fatal(err) 33 | } 34 | 35 | query := make(url.Values) 36 | query.Add("test", "value") 37 | 38 | uri, err := cf.CannedSignedURL("test", "test=value", expireTime) 39 | if err != nil { 40 | t.Fatal(err) 41 | } 42 | 43 | parsed, err := url.Parse(uri) 44 | if err != nil { 45 | t.Fatal(err) 46 | } 47 | 48 | signature := parsed.Query().Get("Signature") 49 | if signature == "" { 50 | t.Fatal("Encoded signature is empty") 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/cloudfront/testdata/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQC0yMzp9DkPAE99DhsEaGkqougLvtmDKri4bZj0fFjmGmjyyjz9 3 | hlrsr87LHVWzH/7igK7040HG1UqypX3ijtJa9+6BKHwBBctboU3y4GfwFwVAOumY 4 | 9UytFpyPlgUFrffZLQAywKkT24OgcfEj0G5kiQn760wFnmSUtOuITo708QIDAQAB 5 | AoGAJUA6+PoZx72Io3wElSPuh5qJteHdb+mdpmLu4XG936wRc/W4G4VTtvGC6tdg 6 | kUhGfOWHJ26sXwwUGDuBdO146m0DkBTuIooy97afpL6hXgL5v4ELHbbuFJcf4Geg 7 | /UAuexvRT1HenYFQ/iXM0LlqI33i8cFRc1A+j0Gseo07gAECQQDYFCn7OUokX+Q8 8 | M2Cwhu7JT1obmP2HwsBtXl0CDDxtOQkuYJP/UqvtdYPz/kRn3yQjoynaCTHYrFz/ 9 | H8oN1nNhAkEA1i9TEpo7RbanIyT4vbc1/5xfjE7Pj0lnGku0QXFp/S+8YxbqhjrQ 10 | 4Qp7TTXIPPqvQhhEpAGGspM460K3F6h7kQJBANJCbMeFa9wRY2ohJIkiA+HoUWph 11 | aPNeUxkZpa+EcJhn08NJPzpIG/ypSYl3duEMhYIYF3WPVO3ea2/mYxsr/oECQFj5 12 | td/fdEoEk7AU1sQxDNyPwF2QC8dxbcRNuKcLD0Wfg/oB9hEm88jYytoLQpCabx3c 13 | 6P7cp3EdmaKZx2erlRECQDYTSK2tS0+VoXSV9JbU08Pbu53j3Zhmp4l0csP+l7EU 14 | U+rRQzKho4X9vpR/VpRGXbw8tTIhojNpHh5ofryVfgk= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/cloudfront/testdata/key.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0yMzp9DkPAE99DhsEaGkqougL 3 | vtmDKri4bZj0fFjmGmjyyjz9hlrsr87LHVWzH/7igK7040HG1UqypX3ijtJa9+6B 4 | KHwBBctboU3y4GfwFwVAOumY9UytFpyPlgUFrffZLQAywKkT24OgcfEj0G5kiQn7 5 | 60wFnmSUtOuITo708QIDAQAB 6 | -----END PUBLIC KEY----- 7 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/cloudwatch/ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-10-21 Carlos Salguero 2 | 3 | * Removed Namespace from the constructor as not all AWS API method needs it 4 | and methods like ListMetrics you could need to call the method without a 5 | Namespace to list all available metrics 6 | 7 | * Added ListMetrics method 8 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | dynamodb_local* 2 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/dynamodb/Makefile: -------------------------------------------------------------------------------- 1 | DYNAMODB_LOCAL_VERSION = 2014-10-07 2 | 3 | launch: DynamoDBLocal.jar 4 | cd dynamodb_local_$(DYNAMODB_LOCAL_VERSION) && java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar 5 | 6 | DynamoDBLocal.jar: dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz 7 | mkdir -p dynamodb_local_$(DYNAMODB_LOCAL_VERSION) 8 | [ -f dynamodb_local_$(DYNAMODB_LOCAL_VERSION)/DynamoDBLocal.jar ] || tar -C dynamodb_local_$(DYNAMODB_LOCAL_VERSION) -zxf dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz 9 | 10 | dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz: 11 | curl -O https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz 12 | 13 | clean: 14 | rm -rf dynamodb_local_$(DYNAMODB_LOCAL_VERSION)* 15 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/dynamodb/README.md: -------------------------------------------------------------------------------- 1 | # Running integration tests 2 | 3 | ## against DynamoDB local 4 | 5 | To download and launch DynamoDB local: 6 | 7 | ```sh 8 | $ make 9 | ``` 10 | 11 | To test: 12 | 13 | ```sh 14 | $ go test -v -amazon 15 | ``` 16 | 17 | ## against real DynamoDB server on us-east 18 | 19 | _WARNING_: Some dangerous operations such as `DeleteTable` will be performed during the tests. Please be careful. 20 | 21 | To test: 22 | 23 | ```sh 24 | $ go test -v -amazon -local=false 25 | ``` 26 | 27 | _Note_: Running tests against real DynamoDB will take several minutes. 28 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/ec2/export_test.go: -------------------------------------------------------------------------------- 1 | package ec2 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "time" 6 | ) 7 | 8 | func Sign(auth aws.Auth, method, path string, params map[string]string, host string) { 9 | sign(auth, method, path, params, host) 10 | } 11 | 12 | func fixedTime() time.Time { 13 | return time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC) 14 | } 15 | 16 | func FakeTime(fakeIt bool) { 17 | if fakeIt { 18 | timeNow = fixedTime 19 | } else { 20 | timeNow = time.Now 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/ec2/sign.go: -------------------------------------------------------------------------------- 1 | package ec2 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha256" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | "sort" 9 | "strings" 10 | ) 11 | 12 | // ---------------------------------------------------------------------------- 13 | // EC2 signing (http://goo.gl/fQmAN) 14 | 15 | var b64 = base64.StdEncoding 16 | 17 | func sign(auth aws.Auth, method, path string, params map[string]string, host string) { 18 | params["AWSAccessKeyId"] = auth.AccessKey 19 | params["SignatureVersion"] = "2" 20 | params["SignatureMethod"] = "HmacSHA256" 21 | 22 | // AWS specifies that the parameters in a signed request must 23 | // be provided in the natural order of the keys. This is distinct 24 | // from the natural order of the encoded value of key=value. 25 | // Percent and gocheck.Equals affect the sorting order. 26 | var keys, sarray []string 27 | for k, _ := range params { 28 | keys = append(keys, k) 29 | } 30 | sort.Strings(keys) 31 | for _, k := range keys { 32 | sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(params[k])) 33 | } 34 | joined := strings.Join(sarray, "&") 35 | payload := method + "\n" + host + "\n" + path + "\n" + joined 36 | hash := hmac.New(sha256.New, []byte(auth.SecretKey)) 37 | hash.Write([]byte(payload)) 38 | signature := make([]byte, b64.EncodedLen(hash.Size())) 39 | b64.Encode(signature, hash.Sum(nil)) 40 | 41 | params["Signature"] = string(signature) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/ec2/sign_test.go: -------------------------------------------------------------------------------- 1 | package ec2_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "github.com/crowdmob/goamz/ec2" 6 | "gopkg.in/check.v1" 7 | ) 8 | 9 | // EC2 ReST authentication docs: http://goo.gl/fQmAN 10 | 11 | var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"} 12 | 13 | func (s *S) TestBasicSignature(c *check.C) { 14 | params := map[string]string{} 15 | ec2.Sign(testAuth, "GET", "/path", params, "localhost") 16 | c.Assert(params["SignatureVersion"], check.Equals, "2") 17 | c.Assert(params["SignatureMethod"], check.Equals, "HmacSHA256") 18 | expected := "6lSe5QyXum0jMVc7cOUz32/52ZnL7N5RyKRk/09yiK4=" 19 | c.Assert(params["Signature"], check.Equals, expected) 20 | } 21 | 22 | func (s *S) TestParamSignature(c *check.C) { 23 | params := map[string]string{ 24 | "param1": "value1", 25 | "param2": "value2", 26 | "param3": "value3", 27 | } 28 | ec2.Sign(testAuth, "GET", "/path", params, "localhost") 29 | expected := "XWOR4+0lmK8bD8CGDGZ4kfuSPbb2JibLJiCl/OPu1oU=" 30 | c.Assert(params["Signature"], check.Equals, expected) 31 | } 32 | 33 | func (s *S) TestManyParams(c *check.C) { 34 | params := map[string]string{ 35 | "param1": "value10", 36 | "param2": "value2", 37 | "param3": "value3", 38 | "param4": "value4", 39 | "param5": "value5", 40 | "param6": "value6", 41 | "param7": "value7", 42 | "param8": "value8", 43 | "param9": "value9", 44 | "param10": "value1", 45 | } 46 | ec2.Sign(testAuth, "GET", "/path", params, "localhost") 47 | expected := "di0sjxIvezUgQ1SIL6i+C/H8lL+U0CQ9frLIak8jkVg=" 48 | c.Assert(params["Signature"], check.Equals, expected) 49 | } 50 | 51 | func (s *S) TestEscaping(c *check.C) { 52 | params := map[string]string{"Nonce": "+ +"} 53 | ec2.Sign(testAuth, "GET", "/path", params, "localhost") 54 | c.Assert(params["Nonce"], check.Equals, "+ +") 55 | expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA=" 56 | c.Assert(params["Signature"], check.Equals, expected) 57 | } 58 | 59 | func (s *S) TestSignatureExample1(c *check.C) { 60 | params := map[string]string{ 61 | "Timestamp": "2009-02-01T12:53:20+00:00", 62 | "Version": "2007-11-07", 63 | "Action": "ListDomains", 64 | } 65 | ec2.Sign(aws.Auth{AccessKey: "access", SecretKey: "secret"}, "GET", "/", params, "sdb.amazonaws.com") 66 | expected := "okj96/5ucWBSc1uR2zXVfm6mDHtgfNv657rRtt/aunQ=" 67 | c.Assert(params["Signature"], check.Equals, expected) 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/ecommerce/ecommerce.go: -------------------------------------------------------------------------------- 1 | package ecommerce 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/crowdmob/goamz/aws" 7 | ) 8 | 9 | // ProductAdvertising provides methods for querying the product advertising API 10 | type ProductAdvertising struct { 11 | service aws.Service 12 | associateTag string 13 | } 14 | 15 | // New creates a new ProductAdvertising client 16 | func New(auth aws.Auth, associateTag string) (p *ProductAdvertising, err error) { 17 | serviceInfo := aws.ServiceInfo{Endpoint: "https://webservices.amazon.com", Signer: aws.V2Signature} 18 | if service, err := aws.NewService(auth, serviceInfo); err == nil { 19 | p = &ProductAdvertising{*service, associateTag} 20 | } 21 | return 22 | } 23 | 24 | // PerformOperation is the main method used for interacting with the product advertising API 25 | func (p *ProductAdvertising) PerformOperation(operation string, params map[string]string) (resp *http.Response, err error) { 26 | params["Operation"] = operation 27 | return p.query(params) 28 | } 29 | 30 | func (p *ProductAdvertising) query(params map[string]string) (resp *http.Response, err error) { 31 | params["Service"] = "AWSECommerceService" 32 | params["AssociateTag"] = p.associateTag 33 | return p.service.Query("GET", "/onca/xml", params) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/elasticache/elasticache_test.go: -------------------------------------------------------------------------------- 1 | package elasticache 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/crowdmob/goamz/aws" 7 | "github.com/crowdmob/goamz/testutil" 8 | check "gopkg.in/check.v1" 9 | ) 10 | 11 | type S struct { 12 | elasticache *ElastiCache 13 | } 14 | 15 | var testServer = testutil.NewHTTPServer() 16 | 17 | func Test(t *testing.T) { 18 | check.TestingT(t) 19 | } 20 | 21 | func (s *S) SetUpSuite(c *check.C) { 22 | testServer.Start() 23 | auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} 24 | s.elasticache = New(auth, aws.Region{ElastiCacheEndpoint: testServer.URL}) 25 | } 26 | 27 | func (s *S) TearDownTest(c *check.C) { 28 | testServer.Flush() 29 | } 30 | 31 | func (s *S) TestDescribeReplicationGroup(c *check.C) { 32 | testServer.Start() 33 | auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} 34 | s.elasticache = New(auth, aws.Region{EC2Endpoint: testServer.URL}) 35 | 36 | testServer.Response(200, nil, DescribeReplicationGroupsResponse) 37 | 38 | resp, err := s.elasticache.DescribeReplicationGroup("test") 39 | req := testServer.WaitRequest() 40 | 41 | c.Assert(err, check.IsNil) 42 | c.Assert(req.URL.Query().Get("Action"), check.Equals, "DescribeReplicationGroup") 43 | 44 | c.Assert(resp.Status, check.Equals, "available") 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/elasticache/responses_test.go: -------------------------------------------------------------------------------- 1 | package elasticache 2 | 3 | var DescribeReplicationGroupsResponse = ` 4 | 5 | 6 | 7 | 8 | example-test-001 9 | example-test-002 10 | example-test-003 11 | 12 | 13 | 14 | 0001 15 | 16 | 6379 17 |
example-test.4q8cbh.ng.0001.euw1.cache.amazonaws.com
18 |
19 | available 20 | 21 | 22 | example-test-001 23 | 24 | 6379 25 |
example-test-001.4q8cbh.0001.euw1.cache.amazonaws.com
26 |
27 | eu-west-1a 28 | 0001 29 | primary 30 |
31 | 32 | example-test-002 33 | 34 | 6379 35 |
example-test-002.4q8cbh.0001.euw1.cache.amazonaws.com
36 |
37 | eu-west-1b 38 | 0001 39 | replica 40 |
41 | 42 | example-test-003 43 | 44 | 6379 45 |
example-test-003.4q8cbh.0001.euw1.cache.amazonaws.com
46 |
47 | eu-west-1c 48 | 0001 49 | replica 50 |
51 |
52 |
53 |
54 | example-test 55 | available 56 | 57 | CH Doc API test 58 |
59 |
60 |
61 | 62 | a84997a2-8141-11e4-b193-ff2ad2b98e65 63 | 64 |
65 | ` 66 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/mturk/example_test.go: -------------------------------------------------------------------------------- 1 | package mturk_test 2 | 3 | import ( 4 | "fmt" 5 | "github.com/crowdmob/goamz/aws" 6 | "github.com/crowdmob/goamz/exp/mturk" 7 | ) 8 | 9 | var turk *mturk.MTurk 10 | 11 | func ExampleNew() { 12 | // These are your AWS tokens. Note that Turk do not support IAM. 13 | // So you'll have to use your main profile's tokens. 14 | var auth = aws.Auth{AccessKey: "", SecretKey: ""} 15 | turk = mturk.New(auth, true) // true to use sandbox mode 16 | } 17 | 18 | func Examplemturk_CreateHIT_withExternalQuestion() { 19 | question := mturk.ExternalQuestion{ 20 | ExternalURL: "http://www.amazon.com", 21 | FrameHeight: 200, 22 | } 23 | reward := mturk.Price{ 24 | Amount: "0.01", 25 | CurrencyCode: "USD", 26 | } 27 | 28 | hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "annotation") 29 | 30 | if err == nil { 31 | fmt.Println(hit) 32 | } 33 | } 34 | 35 | func Examplemturk_CreateHIT_withHTMLQuestion() { 36 | question := mturk.HTMLQuestion{ 37 | HTMLContent: mturk.HTMLContent{` 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 |

What's up?

48 |

49 |

50 | 51 | 52 | 53 | ]]>`}, 54 | FrameHeight: 200, 55 | } 56 | reward := mturk.Price{ 57 | Amount: "0.01", 58 | CurrencyCode: "USD", 59 | } 60 | 61 | hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "") 62 | 63 | if err == nil { 64 | fmt.Println(hit) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/mturk/export_test.go: -------------------------------------------------------------------------------- 1 | package mturk 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | ) 6 | 7 | func Sign(auth aws.Auth, service, method, timestamp string, params map[string]string) { 8 | sign(auth, service, method, timestamp, params) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/mturk/sign.go: -------------------------------------------------------------------------------- 1 | package mturk 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha1" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | ) 9 | 10 | var b64 = base64.StdEncoding 11 | 12 | // ---------------------------------------------------------------------------- 13 | // Mechanical Turk signing (http://goo.gl/wrzfn) 14 | func sign(auth aws.Auth, service, method, timestamp string, params map[string]string) { 15 | payload := service + method + timestamp 16 | hash := hmac.New(sha1.New, []byte(auth.SecretKey)) 17 | hash.Write([]byte(payload)) 18 | signature := make([]byte, b64.EncodedLen(hash.Size())) 19 | b64.Encode(signature, hash.Sum(nil)) 20 | 21 | params["Signature"] = string(signature) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/mturk/sign_test.go: -------------------------------------------------------------------------------- 1 | package mturk_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "github.com/crowdmob/goamz/exp/mturk" 6 | "gopkg.in/check.v1" 7 | ) 8 | 9 | // Mechanical Turk REST authentication docs: http://goo.gl/wrzfn 10 | 11 | var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"} 12 | 13 | // == fIJy9wCApBNL2R4J2WjJGtIBFX4= 14 | func (s *S) TestBasicSignature(c *check.C) { 15 | params := map[string]string{} 16 | mturk.Sign(testAuth, "AWSMechanicalTurkRequester", "CreateHIT", "2012-02-16T20:30:47Z", params) 17 | expected := "b/TnvzrdeD/L/EyzdFrznPXhido=" 18 | c.Assert(params["Signature"], check.Equals, expected) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/sdb/export_test.go: -------------------------------------------------------------------------------- 1 | package sdb 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | ) 6 | 7 | func Sign(auth aws.Auth, method, path string, params map[string][]string, headers map[string][]string) { 8 | sign(auth, method, path, params, headers) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/sdb/sign.go: -------------------------------------------------------------------------------- 1 | package sdb 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha256" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | "net/http" 9 | "net/url" 10 | "sort" 11 | "strings" 12 | ) 13 | 14 | var b64 = base64.StdEncoding 15 | 16 | // ---------------------------------------------------------------------------- 17 | // SimpleDB signing (http://goo.gl/CaY81) 18 | 19 | func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) { 20 | var host string 21 | for k, v := range headers { 22 | k = strings.ToLower(k) 23 | switch k { 24 | case "host": 25 | host = v[0] 26 | } 27 | } 28 | 29 | // set up some defaults used for signing the request 30 | params["AWSAccessKeyId"] = []string{auth.AccessKey} 31 | params["SignatureVersion"] = []string{"2"} 32 | params["SignatureMethod"] = []string{"HmacSHA256"} 33 | if auth.Token() != "" { 34 | params["SecurityToken"] = []string{auth.Token()} 35 | } 36 | 37 | // join up all the incoming params 38 | var sarray []string 39 | for k, v := range params { 40 | sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v[0])) 41 | } 42 | sort.StringSlice(sarray).Sort() 43 | joined := strings.Join(sarray, "&") 44 | 45 | // create the payload, sign it and create the signature 46 | payload := strings.Join([]string{method, host, "/", joined}, "\n") 47 | hash := hmac.New(sha256.New, []byte(auth.SecretKey)) 48 | hash.Write([]byte(payload)) 49 | signature := make([]byte, b64.EncodedLen(hash.Size())) 50 | b64.Encode(signature, hash.Sum(nil)) 51 | 52 | // add the signature to the outgoing params 53 | params["Signature"] = []string{string(signature)} 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/sdb/sign_test.go: -------------------------------------------------------------------------------- 1 | package sdb_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "github.com/crowdmob/goamz/exp/sdb" 6 | "gopkg.in/check.v1" 7 | ) 8 | 9 | // SimpleDB ReST authentication docs: http://goo.gl/CaY81 10 | 11 | var testAuth = aws.Auth{AccessKey: "access-key-id-s8eBOWuU", SecretKey: "secret-access-key-UkQjTLd9"} 12 | 13 | func (s *S) TestSignExampleDomainCreate(c *check.C) { 14 | method := "GET" 15 | params := map[string][]string{ 16 | "Action": {"CreateDomain"}, 17 | "DomainName": {"MyDomain"}, 18 | "Timestamp": {"2011-08-20T07:23:57+12:00"}, 19 | "Version": {"2009-04-15"}, 20 | } 21 | headers := map[string][]string{ 22 | "Host": {"sdb.amazonaws.com"}, 23 | } 24 | sdb.Sign(testAuth, method, "", params, headers) 25 | expected := "ot2JaeeqMRJqgAqW67hkzUlffgxdOz4RykbrECB+tDU=" 26 | c.Assert(params["Signature"], check.DeepEquals, []string{expected}) 27 | } 28 | 29 | // Do a few test methods which takes combinations of params 30 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/ses/delivery_notification_test.go: -------------------------------------------------------------------------------- 1 | package ses_test 2 | 3 | import ( 4 | "encoding/json" 5 | "gopkg.in/check.v1" 6 | 7 | "github.com/crowdmob/goamz/exp/ses" 8 | ) 9 | 10 | func (s *S) TestSNSBounceNotificationUnmarshalling(c *check.C) { 11 | notification := ses.SNSNotification{} 12 | err := json.Unmarshal([]byte(SNSBounceNotification), ¬ification) 13 | c.Assert(err, check.IsNil) 14 | c.Assert(notification.Bounce, check.NotNil) 15 | } 16 | 17 | func (s *S) TestSNSComplaintNotificationUnmarshalling(c *check.C) { 18 | notification := ses.SNSNotification{} 19 | err := json.Unmarshal([]byte(SNSComplaintNotification), ¬ification) 20 | c.Assert(err, check.IsNil) 21 | c.Assert(notification.Complaint, check.NotNil) 22 | } 23 | 24 | func (s *S) TestSNSDeliveryNotificationUnmarshalling(c *check.C) { 25 | notification := ses.SNSNotification{} 26 | err := json.Unmarshal([]byte(SNSDeliveryNotification), ¬ification) 27 | c.Assert(err, check.IsNil) 28 | c.Assert(notification.Delivery, check.NotNil) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/ses/mailbox_simulator.go: -------------------------------------------------------------------------------- 1 | package ses 2 | 3 | var ( 4 | tEST_TO_ADDRESSES = []string{ 5 | "success@simulator.amazonses.com", 6 | "bounce@simulator.amazonses.com", 7 | "ooto@simulator.amazonses.com", 8 | "complaint@simulator.amazonses.com", 9 | "suppressionlist@simulator.amazonses.com"} 10 | tEST_CC_ADDRESSES = []string{} 11 | tEST_BCC_ADDRESSES = []string{} 12 | ) 13 | 14 | const ( 15 | tEST_EMAIL_SUBJECT = "goamz TestSESIntegration" 16 | tEST_TEXT_BODY = "This is a test email send by SimulateDelivery." 17 | 18 | tEST_HTML_BODY = ` 19 | 20 | 21 |

This is a test email send by SimulateDelivery.

22 |

Foo bar baz

23 | 24 | 25 | ` 26 | ) 27 | 28 | // This is an helper function to send emails to the mailbox simulator. 29 | // http://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-simulator.html 30 | // 31 | // from: the source email address registered in your SES account 32 | func (s *SES) SimulateDelivery(from string) (*SendEmailResponse, error) { 33 | destination := NewDestination(tEST_TO_ADDRESSES, 34 | tEST_CC_ADDRESSES, tEST_BCC_ADDRESSES) 35 | message := NewMessage(tEST_EMAIL_SUBJECT, tEST_TEXT_BODY, tEST_HTML_BODY) 36 | 37 | return s.SendEmail(from, destination, message) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/exp/ses/responses_test.go: -------------------------------------------------------------------------------- 1 | package ses_test 2 | 3 | var TestSendEmailError = ` 4 | 5 | 6 | 7 | Sender 8 | MessageRejected 9 | Email address is not verified. 10 | 11 | 21d1e58d-28b2-4d5f-a974-669c3c67674f 12 | 13 | ` 14 | 15 | var TestSendEmailOk = ` 16 | 17 | 18 | 19 | 00000131d51d2292-159ad6eb-077c-46e6-ad09-ae7c05925ed4-000000 20 | 21 | 22 | d5964849-c866-11e0-9beb-01a62d68c57f 23 | 24 | 25 | ` 26 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/iam/iamt_test.go: -------------------------------------------------------------------------------- 1 | package iam_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "github.com/crowdmob/goamz/iam" 6 | "github.com/crowdmob/goamz/iam/iamtest" 7 | "gopkg.in/check.v1" 8 | ) 9 | 10 | // LocalServer represents a local ec2test fake server. 11 | type LocalServer struct { 12 | auth aws.Auth 13 | region aws.Region 14 | srv *iamtest.Server 15 | } 16 | 17 | func (s *LocalServer) SetUp(c *check.C) { 18 | srv, err := iamtest.NewServer() 19 | c.Assert(err, check.IsNil) 20 | c.Assert(srv, check.NotNil) 21 | 22 | s.srv = srv 23 | s.region = aws.Region{IAMEndpoint: srv.URL()} 24 | } 25 | 26 | // LocalServerSuite defines tests that will run 27 | // against the local iamtest server. It includes 28 | // tests from ClientTests. 29 | type LocalServerSuite struct { 30 | srv LocalServer 31 | ClientTests 32 | } 33 | 34 | var _ = check.Suite(&LocalServerSuite{}) 35 | 36 | func (s *LocalServerSuite) SetUpSuite(c *check.C) { 37 | s.srv.SetUp(c) 38 | s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/iam/sign.go: -------------------------------------------------------------------------------- 1 | package iam 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha256" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | "sort" 9 | "strings" 10 | ) 11 | 12 | // ---------------------------------------------------------------------------- 13 | // Version 2 signing (http://goo.gl/RSRp5) 14 | 15 | var b64 = base64.StdEncoding 16 | 17 | func sign(auth aws.Auth, method, path string, params map[string]string, host string) { 18 | params["AWSAccessKeyId"] = auth.AccessKey 19 | params["SignatureVersion"] = "2" 20 | params["SignatureMethod"] = "HmacSHA256" 21 | if auth.Token() != "" { 22 | params["SecurityToken"] = auth.Token() 23 | } 24 | 25 | var sarray []string 26 | for k, v := range params { 27 | sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v)) 28 | } 29 | sort.StringSlice(sarray).Sort() 30 | joined := strings.Join(sarray, "&") 31 | payload := method + "\n" + host + "\n" + path + "\n" + joined 32 | hash := hmac.New(sha256.New, []byte(auth.SecretKey)) 33 | hash.Write([]byte(payload)) 34 | signature := make([]byte, b64.EncodedLen(hash.Size())) 35 | b64.Encode(signature, hash.Sum(nil)) 36 | 37 | params["Signature"] = string(signature) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/kinesis/query.go: -------------------------------------------------------------------------------- 1 | package kinesis 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | type msi map[string]interface{} 8 | type Query struct { 9 | buffer msi 10 | } 11 | 12 | func NewEmptyQuery() *Query { 13 | return &Query{msi{}} 14 | } 15 | 16 | func NewQueryWithStream(streamName string) *Query { 17 | q := &Query{msi{}} 18 | q.AddStreamName(streamName) 19 | return q 20 | } 21 | 22 | func (q *Query) AddExclusiveStartShardId(shardId string) { 23 | q.buffer["ExclusiveStartShardId"] = shardId 24 | } 25 | 26 | func (q *Query) AddLimit(limit int) { 27 | q.buffer["Limit"] = limit 28 | } 29 | 30 | func (q *Query) AddStreamName(name string) { 31 | q.buffer["StreamName"] = name 32 | } 33 | 34 | func (q *Query) AddShardCount(count int) { 35 | q.buffer["ShardCount"] = count 36 | } 37 | 38 | func (q *Query) AddShardIterator(iterator string) { 39 | q.buffer["ShardIterator"] = iterator 40 | } 41 | 42 | func (q *Query) AddShardId(id string) { 43 | q.buffer["ShardId"] = id 44 | } 45 | 46 | func (q *Query) AddShardIteratorType(t ShardIteratorType) { 47 | q.buffer["ShardIteratorType"] = t 48 | } 49 | 50 | func (q *Query) AddStartingSequenceNumber(sequenceNumber string) { 51 | q.buffer["StartingSequenceNumber"] = sequenceNumber 52 | } 53 | 54 | func (q *Query) AddData(data []byte) { 55 | q.buffer["Data"] = data 56 | } 57 | 58 | func (q *Query) AddExplicitHashKey(hashKey string) { 59 | q.buffer["ExplicitHashKey"] = hashKey 60 | } 61 | 62 | func (q *Query) AddPartitionKey(partitionKey string) { 63 | q.buffer["PartitionKey"] = partitionKey 64 | } 65 | 66 | func (q *Query) AddSequenceNumberForOrdering(sequenceNumber string) { 67 | q.buffer["SequenceNumberForOrdering"] = sequenceNumber 68 | } 69 | 70 | func (q *Query) AddShardToMerge(shard string) { 71 | q.buffer["ShardToMerge"] = shard 72 | } 73 | 74 | func (q *Query) AddAdjacentShardToMerge(shard string) { 75 | q.buffer["AdjacentShardToMerge"] = shard 76 | } 77 | 78 | func (q *Query) AddShardToSplit(shard string) { 79 | q.buffer["ShardToSplit"] = shard 80 | } 81 | 82 | func (q *Query) AddNewStartingHashKey(hashKey string) { 83 | q.buffer["NewStartingHashKey"] = hashKey 84 | } 85 | 86 | func (q *Query) String() string { 87 | bytes, err := json.Marshal(q.buffer) 88 | if err != nil { 89 | panic(err) 90 | } 91 | return string(bytes) 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/s3/export_test.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | ) 6 | 7 | var originalStrategy = attempts 8 | 9 | func SetAttemptStrategy(s *aws.AttemptStrategy) { 10 | if s == nil { 11 | attempts = originalStrategy 12 | } else { 13 | attempts = *s 14 | } 15 | } 16 | 17 | func Sign(auth aws.Auth, method, path string, params, headers map[string][]string) { 18 | sign(auth, method, path, params, headers) 19 | } 20 | 21 | func SetListPartsMax(n int) { 22 | listPartsMax = n 23 | } 24 | 25 | func SetListMultiMax(n int) { 26 | listMultiMax = n 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/s3/s3t_test.go: -------------------------------------------------------------------------------- 1 | package s3_test 2 | 3 | import ( 4 | "github.com/crowdmob/goamz/aws" 5 | "github.com/crowdmob/goamz/s3" 6 | "github.com/crowdmob/goamz/s3/s3test" 7 | "gopkg.in/check.v1" 8 | ) 9 | 10 | type LocalServer struct { 11 | auth aws.Auth 12 | region aws.Region 13 | srv *s3test.Server 14 | config *s3test.Config 15 | } 16 | 17 | func (s *LocalServer) SetUp(c *check.C) { 18 | srv, err := s3test.NewServer(s.config) 19 | c.Assert(err, check.IsNil) 20 | c.Assert(srv, check.NotNil) 21 | 22 | s.srv = srv 23 | s.region = aws.Region{ 24 | Name: "faux-region-1", 25 | S3Endpoint: srv.URL(), 26 | S3LocationConstraint: true, // s3test server requires a LocationConstraint 27 | } 28 | } 29 | 30 | // LocalServerSuite defines tests that will run 31 | // against the local s3test server. It includes 32 | // selected tests from ClientTests; 33 | // when the s3test functionality is sufficient, it should 34 | // include all of them, and ClientTests can be simply embedded. 35 | type LocalServerSuite struct { 36 | srv LocalServer 37 | clientTests ClientTests 38 | } 39 | 40 | var ( 41 | // run tests twice, once in us-east-1 mode, once not. 42 | _ = check.Suite(&LocalServerSuite{}) 43 | _ = check.Suite(&LocalServerSuite{ 44 | srv: LocalServer{ 45 | config: &s3test.Config{ 46 | Send409Conflict: true, 47 | }, 48 | }, 49 | }) 50 | ) 51 | 52 | func (s *LocalServerSuite) SetUpSuite(c *check.C) { 53 | s.srv.SetUp(c) 54 | s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region) 55 | 56 | // TODO Sadly the fake server ignores auth completely right now. :-( 57 | s.clientTests.authIsBroken = true 58 | s.clientTests.Cleanup() 59 | } 60 | 61 | func (s *LocalServerSuite) TearDownTest(c *check.C) { 62 | s.clientTests.Cleanup() 63 | } 64 | 65 | func (s *LocalServerSuite) TestBasicFunctionality(c *check.C) { 66 | s.clientTests.TestBasicFunctionality(c) 67 | } 68 | 69 | func (s *LocalServerSuite) TestGetNotFound(c *check.C) { 70 | s.clientTests.TestGetNotFound(c) 71 | } 72 | 73 | func (s *LocalServerSuite) TestBucketList(c *check.C) { 74 | s.clientTests.TestBucketList(c) 75 | } 76 | 77 | func (s *LocalServerSuite) TestDoublePutBucket(c *check.C) { 78 | s.clientTests.TestDoublePutBucket(c) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/sns/http_notifications.go: -------------------------------------------------------------------------------- 1 | package sns 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | const ( 8 | MESSAGE_TYPE_SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation" 9 | MESSAGE_TYPE_UNSUBSCRIBE_CONFIRMATION = "UnsubscribeConfirmation" 10 | MESSAGE_TYPE_NOTIFICATION = "Notification" 11 | ) 12 | 13 | // Json http notifications 14 | // SNS posts those to your http url endpoint if http is selected as delivery method. 15 | // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-subscription-confirmation-json 16 | // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-notification-json 17 | // http://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-unsubscribe-confirmation-json 18 | type HttpNotification struct { 19 | Type string `json:"Type"` 20 | MessageId string `json:"MessageId"` 21 | Token string `json:"Token" optional` // Only for subscribe and unsubscribe 22 | TopicArn string `json:"TopicArn"` 23 | Subject string `json:"Subject" optional` // Only for Notification 24 | Message string `json:"Message"` 25 | SubscribeURL string `json:"SubscribeURL" optional` // Only for subscribe and unsubscribe 26 | Timestamp time.Time `json:"Timestamp"` 27 | SignatureVersion string `json:"SignatureVersion"` 28 | Signature string `json:"Signature"` 29 | SigningCertURL string `json:"SigningCertURL"` 30 | UnsubscribeURL string `json:"UnsubscribeURL" optional` // Only for notifications 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/sqs/Makefile: -------------------------------------------------------------------------------- 1 | include $(GOROOT)/src/Make.inc 2 | 3 | TARG=launchpad.net/goamz/sqs 4 | 5 | GOFILES=\ 6 | sqs.go\ 7 | sign.go\ 8 | 9 | include $(GOROOT)/src/Make.pkg 10 | 11 | GOFMT=gofmt 12 | BADFMT=$(shell $(GOFMT) -l $(GOFILES) 2> /dev/null) 13 | 14 | gofmt: $(BADFMT) 15 | @for F in $(BADFMT); do $(GOFMT) -w $$F && echo $$F; done 16 | 17 | ifneq ($(BADFMT),) 18 | ifneq ($(MAKECMDGOALS), gofmt) 19 | #$(warning WARNING: make gofmt: $(BADFMT)) 20 | endif 21 | endif 22 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/sqs/README.md: -------------------------------------------------------------------------------- 1 | Amazon Simple Queue Service API Client Written in Golang. 2 | ========================================================= 3 | 4 | Merged from https://github.com/Mistobaan/sqs 5 | 6 | Installation 7 | ------------ 8 | 9 | go get github.com/crowdmob/goamz/sqs 10 | 11 | 12 | Testing 13 | ------- 14 | 15 | go test . 16 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/sqs/md5.go: -------------------------------------------------------------------------------- 1 | package sqs 2 | 3 | /* 4 | * Performs the MD5 algorithm for attribute responses described in 5 | * the AWS documentation here: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSMessageAttributes.html#sqs-attrib-md5 6 | */ 7 | 8 | import ( 9 | "crypto/md5" 10 | "encoding/binary" 11 | "sort" 12 | ) 13 | 14 | // Returns length of string as an Big Endian byte array 15 | func getStringLengthAsByteArray(s string) []byte { 16 | var res []byte = make([]byte, 4) 17 | binary.BigEndian.PutUint32(res, uint32(len(s))) 18 | 19 | return res 20 | } 21 | 22 | // How to calculate the MD5 of Attributes 23 | func calculateAttributeMD5(attributes map[string]string) []byte { 24 | 25 | // We're going to walk attributes in alpha-sorted order 26 | var keys []string 27 | 28 | for k := range attributes { 29 | keys = append(keys, k) 30 | } 31 | 32 | sort.Strings(keys) 33 | 34 | // Now we'll build our encoded string 35 | var encoded []byte 36 | 37 | for _, k := range keys { 38 | v := attributes[k] 39 | t := "String" 40 | 41 | encodedItems := [][]byte{ 42 | getStringLengthAsByteArray(k), 43 | []byte(k), // Name 44 | getStringLengthAsByteArray(t), 45 | []byte(t), // Data Type ("String") 46 | []byte{0x01}, // "String Value" (0x01) 47 | getStringLengthAsByteArray(v), 48 | []byte(v), // Value 49 | } 50 | 51 | // Append each of these to our encoding 52 | for _, item := range encodedItems { 53 | encoded = append(encoded, item...) 54 | } 55 | } 56 | 57 | res := md5.Sum(encoded) 58 | 59 | // Return MD5 sum 60 | return res[:] 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/sqs/sign.go: -------------------------------------------------------------------------------- 1 | package sqs 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha256" 6 | "encoding/base64" 7 | "github.com/crowdmob/goamz/aws" 8 | "sort" 9 | "strings" 10 | ) 11 | 12 | var b64 = base64.StdEncoding 13 | 14 | func sign(auth aws.Auth, method, path string, params map[string]string, host string) { 15 | params["AWSAccessKeyId"] = auth.AccessKey 16 | params["SignatureVersion"] = "2" 17 | params["SignatureMethod"] = "HmacSHA256" 18 | 19 | var sarray []string 20 | for k, v := range params { 21 | sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v)) 22 | } 23 | sort.StringSlice(sarray).Sort() 24 | joined := strings.Join(sarray, "&") 25 | payload := method + "\n" + host + "\n" + path + "\n" + joined 26 | hash := hmac.New(sha256.New, []byte(auth.SecretKey)) 27 | hash.Write([]byte(payload)) 28 | signature := make([]byte, b64.EncodedLen(hash.Size())) 29 | b64.Encode(signature, hash.Sum(nil)) 30 | 31 | params["Signature"] = string(signature) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/crowdmob/goamz/testutil/suite.go: -------------------------------------------------------------------------------- 1 | package testutil 2 | 3 | import ( 4 | "flag" 5 | "github.com/crowdmob/goamz/aws" 6 | "gopkg.in/check.v1" 7 | ) 8 | 9 | // Amazon must be used by all tested packages to determine whether to 10 | // run functional tests against the real AWS servers. 11 | var Amazon bool 12 | 13 | func init() { 14 | flag.BoolVar(&Amazon, "amazon", false, "Enable tests against amazon server") 15 | } 16 | 17 | type LiveSuite struct { 18 | auth aws.Auth 19 | } 20 | 21 | func (s *LiveSuite) SetUpSuite(c *check.C) { 22 | if !Amazon { 23 | c.Skip("amazon tests not enabled (-amazon flag)") 24 | } 25 | auth, err := aws.EnvAuth() 26 | if err != nil { 27 | c.Fatal(err.Error()) 28 | } 29 | s.auth = auth 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/raw/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Eleanor McHugh 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | The Software shall be used for Good, not Evil. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/raw/README: -------------------------------------------------------------------------------- 1 | == Disclaimer == 2 | The RAW package circumvents and subverts Go's type system. As such it should be used with extreme caution and only 3 | when absolutely necessary. Incautious use can and will lead to memory corruption. As such no warranty can be provided 4 | as to its suitability or fitness for purpose. 5 | 6 | Just to reiterate: MISUSE WILL RESULT IN MEMORY CORRUPTION. 7 | 8 | 9 | == License == 10 | 11 | RAW is dual-licensed. 12 | 13 | The library can be included in your project as "Random Access Woe" under the BSD-derived license in LICENSE. 14 | 15 | "Read it And Weep" is the closed-source variant of the library. It is in all particulars identical to the open-source 16 | version but requires a commercial usage license and in the process hides your shame for abusing Go in this manner. 17 | Further details of commercial license costs are available from the author on request. 18 | 19 | 20 | == About == 21 | 22 | RAW is a high-level interface to Go's unsafe and reflection packages, designed to ease both generic programming and 23 | low-level memory access. 24 | 25 | RAW allows any type with identifiable contiguous memory allocation to be converted to a byte slice which can then 26 | be manipulated using many of the standard IO interfaces provided by the core library. This is very unsafe but for 27 | certain system programming tasks can be very useful. In particular it facilitates the sharing of memory buffers with 28 | language runtimes and any number of related tricks such as polymorphic variables, mixed-content arrays and binary 29 | data marshalling. 30 | 31 | Documentation is currently sparse but will improve over time. I have tried to keep nomenclature clear to assist with 32 | figuring our how the library should be used and there are also extensive tests which demonstrate all of the library 33 | types and their methods in use. 34 | 35 | 36 | == History == 37 | 38 | The RAW package began life as a research spike of the GoLightly virtual machine project and was originally to be called 39 | either "Dangerous" or "Deadly" to reflect the unpleasant consequences of misuse. A friend suggested "Random Access Woe" 40 | and the name stuck. -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/raw/runtime.go: -------------------------------------------------------------------------------- 1 | package raw 2 | 3 | func Throw() { 4 | panic(nil) 5 | } 6 | 7 | func Catch(f func()) { 8 | defer func() { 9 | if x := recover(); x != nil { 10 | panic(x) 11 | } 12 | }() 13 | f() 14 | } 15 | 16 | func CatchAll(f func()) { 17 | defer func() { 18 | recover() 19 | }() 20 | f() 21 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/raw/runtime_test.go: -------------------------------------------------------------------------------- 1 | package raw 2 | 3 | import "testing" 4 | 5 | func TestThrow(t *testing.T) {} 6 | 7 | func TestCatch(t *testing.T) {} 8 | 9 | func TestCatchAll(t *testing.T) {} -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/raw/type_test.go: -------------------------------------------------------------------------------- 1 | package raw 2 | 3 | import "testing" 4 | 5 | func TestConcreteValue(t *testing.T) { t.Log("Test not yet implemented") } 6 | func TestMakeAddressable(t *testing.T) { t.Log("Test not yet implemented") } 7 | func TestAssign(t *testing.T) { t.Log("Test not yet implemented") } 8 | 9 | func TestCompatible(t *testing.T) { 10 | ConfirmCompatible := func(l, r interface{}) { 11 | switch { 12 | case !Compatible(l, r): t.Fatalf("Compatible(%v, %v) should be true but is false", l, r) 13 | case !Compatible(r, l): t.Fatalf("Compatible(%v, %v) should be true but is false", l, r) 14 | } 15 | } 16 | 17 | RefuteCompatible := func(l, r interface{}) { 18 | switch { 19 | case Compatible(l, r): t.Fatalf("Compatible(%v, %v) should be false but is true", l, r) 20 | case Compatible(r, l): t.Fatalf("Compatible(%v, %v) should be false but is true", l, r) 21 | } 22 | } 23 | 24 | ConfirmCompatible([]int{}, []int{}) 25 | ConfirmCompatible([0]int{}, [0]int{}) 26 | ConfirmCompatible([0]int{}, [1]int{}) 27 | ConfirmCompatible([]int{ 0 }, [1]int{}) 28 | 29 | RefuteCompatible([]int{}, []uint{}) 30 | RefuteCompatible([0]int{}, [0]uint{}) 31 | RefuteCompatible([0]int{}, [1]uint{}) 32 | RefuteCompatible([]int{ 0 }, [1]uint{}) 33 | 34 | ConfirmCompatible([]int{}, map[int]int{}) 35 | ConfirmCompatible([0]int{}, map[int]int{}) 36 | ConfirmCompatible([1]int{}, map[int]int{}) 37 | ConfirmCompatible([]int{ 0 }, map[int]int{}) 38 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Eleanor McHugh 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | Included in all copies or substantial portions of the Software. 14 | 15 | The Software shall be used for Good, not Evil. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/README: -------------------------------------------------------------------------------- 1 | == About == 2 | 3 | The Sets package provides implementations of hash-based Sets for all of Go's basic types. Currently there's no documentation but the extensive test suite Includes numerous examples of how to use slices to solve common tasks. 4 | 5 | The package has its origins in research for the GoLightly virtual machine project. I hope you will find it useful. 6 | -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/complex64.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type c64map map[complex64] bool 8 | 9 | func (m c64map) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m c64map) Member(i interface{}) (r bool) { 14 | if i, ok := i.(complex64); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m c64map) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []complex64: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case complex64: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m c64map) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(complex64): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | func (m c64map) String() (t string) { 51 | elements := slices.C64Slice{} 52 | m.Each(func(v complex64) { 53 | elements = append(elements, v) 54 | }) 55 | slices.Sort(elements) 56 | return elements.String() 57 | } 58 | 59 | 60 | type c64set struct { 61 | c64map 62 | } 63 | 64 | func C64Set(v... complex64) (r c64set) { 65 | r.c64map = make(c64map) 66 | r.Include(v) 67 | return 68 | } 69 | 70 | func (s c64set) Empty() Set { 71 | return C64Set() 72 | } 73 | 74 | func (s c64set) Equal(o interface{}) (r bool) { 75 | if o, ok := o.(Set); ok { 76 | if r = s.Len() == o.Len(); r { 77 | s.Each(func(v complex64) { 78 | if !o.Member(v) { 79 | r = false 80 | } 81 | }) 82 | } 83 | } 84 | return 85 | } 86 | 87 | func (s c64set) Sum() interface{} { 88 | var r complex64 89 | s.Each(func(v complex64) { 90 | r += v 91 | }) 92 | return r 93 | } 94 | 95 | func (s c64set) Product() interface{} { 96 | r := complex64(1) 97 | s.Each(func(v complex64) { 98 | r *= v 99 | }) 100 | return r 101 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/error.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type emap map[error] bool 8 | 9 | func (m emap) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m emap) Member(i interface{}) (r bool) { 14 | if i, ok := i.(error); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m emap) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []error: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case error: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m emap) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(error): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | func (m emap) String() (t string) { 51 | elements := slices.ESlice{} 52 | m.Each(func(v error) { 53 | elements = append(elements, v) 54 | }) 55 | slices.Sort(elements) 56 | return elements.String() 57 | } 58 | 59 | 60 | type eset struct { 61 | emap 62 | } 63 | 64 | func ESet(v... error) (r eset) { 65 | r.emap = make(emap) 66 | r.Include(v) 67 | return 68 | } 69 | 70 | func (s eset) Empty() Set { 71 | return ESet() 72 | } 73 | 74 | func (s eset) Intersection(o Set) Set { 75 | r := ESet() 76 | s.Each(func(v error) { 77 | if o.Member(v) { 78 | r.Include(v) 79 | } 80 | }) 81 | return r 82 | } 83 | 84 | func (s eset) Union(o Set) Set { 85 | r := ESet() 86 | s.Each(func(v error) { 87 | r.Include(v) 88 | }) 89 | o.Each(func(v error) { 90 | r.Include(v) 91 | }) 92 | return r 93 | } 94 | 95 | func (s eset) Difference(o Set) Set { 96 | r := ESet() 97 | s.Each(func(v error) { 98 | if !o.Member(v) { 99 | r.Include(v) 100 | } 101 | }) 102 | return r 103 | } 104 | 105 | func (s eset) Equal(o interface{}) (r bool) { 106 | if o, ok := o.(Set); ok { 107 | if r = s.Len() == o.Len(); r { 108 | s.Each(func(v error) { 109 | if !o.Member(v) { 110 | r = false 111 | } 112 | }) 113 | } 114 | } 115 | return 116 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/error_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | type Errno int 9 | 10 | func (e Errno) Error() (err string) { 11 | return fmt.Sprintf("(E%v)", int(e)) 12 | } 13 | 14 | const ( 15 | E0 = Errno(iota) 16 | E1 17 | E2 18 | E3 19 | E4 20 | ) 21 | 22 | func TestEString(t *testing.T) { 23 | ConfirmString := func(s eset, r string) { 24 | if v := s.String(); r != v { 25 | t.Errorf("String() expected %v but produced %v", r, v) 26 | } 27 | } 28 | 29 | ConfirmString(ESet(), "()") 30 | // ConfirmString(ESet(E0, E1), "(E0 E1)") 31 | // ConfirmString(ESet(E1, E0), "(E0 E1)") 32 | // ConfirmString(ESet(E0, E1, E2, E3, E4), "(E0 E1 E2 E3 E4)") 33 | } 34 | 35 | func TestEMember(t *testing.T) { 36 | ConfirmMember := func(s eset, x error, r bool) { 37 | if v := s.Member(x); r != v { 38 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 39 | } 40 | } 41 | 42 | ConfirmMember(ESet(), E0, false) 43 | ConfirmMember(ESet(E0), E0, true) 44 | ConfirmMember(ESet(E0, E1), E0, true) 45 | ConfirmMember(ESet(E0, E1), E1, true) 46 | ConfirmMember(ESet(E0, E1), E2, false) 47 | } 48 | 49 | func TestEEqual(t *testing.T) { 50 | ConfirmEqual := func(s, x eset, r bool) { 51 | if v := s.Equal(x); r != v { 52 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 53 | } 54 | } 55 | 56 | ConfirmEqual(ESet(), ESet(), true) 57 | ConfirmEqual(ESet(E0), ESet(), false) 58 | ConfirmEqual(ESet(), ESet(E0), false) 59 | ConfirmEqual(ESet(E0), ESet(E0), true) 60 | ConfirmEqual(ESet(E0, E0), ESet(E0), true) 61 | ConfirmEqual(ESet(E0), ESet(E0, E0), true) 62 | ConfirmEqual(ESet(E0, E1), ESet(E0, E0), false) 63 | ConfirmEqual(ESet(E0, E1), ESet(E0, E1), true) 64 | ConfirmEqual(ESet(E0, E1), ESet(E1, E0), true) 65 | ConfirmEqual(ESet(E0, E1), ESet(E1, E1), false) 66 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/int.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type imap map[int] bool 8 | 9 | func (m imap) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m imap) Member(i interface{}) (r bool) { 14 | if i, ok := i.(int); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m imap) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []int: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case int: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m imap) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(int): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | 51 | type iset struct { 52 | imap 53 | } 54 | 55 | func ISet(v... int) (r iset) { 56 | r.imap = make(imap) 57 | r.Include(v) 58 | return 59 | } 60 | 61 | func (s iset) Empty() Set { 62 | return ISet() 63 | } 64 | 65 | func (s iset) String() (t string) { 66 | elements := slices.ISlice{} 67 | s.Each(func(v int) { 68 | elements = append(elements, v) 69 | }) 70 | slices.Sort(elements) 71 | return elements.String() 72 | } 73 | 74 | func (s iset) Intersection(o Set) Set { 75 | r := ISet() 76 | s.Each(func(v int) { 77 | if o.Member(v) { 78 | r.Include(v) 79 | } 80 | }) 81 | return r 82 | } 83 | 84 | func (s iset) Union(o Set) Set { 85 | r := ISet() 86 | s.Each(func(v int) { 87 | r.Include(v) 88 | }) 89 | o.Each(func(v int) { 90 | r.Include(v) 91 | }) 92 | return r 93 | } 94 | 95 | func (s iset) Difference(o Set) Set { 96 | r := ISet() 97 | s.Each(func(v int) { 98 | if !o.Member(v) { 99 | r.Include(v) 100 | } 101 | }) 102 | return r 103 | } 104 | 105 | func (s iset) Equal(o interface{}) (r bool) { 106 | if o, ok := o.(Set); ok { 107 | if r = s.Len() == o.Len(); r { 108 | s.Each(func(v int) { 109 | if !o.Member(v) { 110 | r = false 111 | } 112 | }) 113 | } 114 | } 115 | return 116 | } 117 | 118 | func (s iset) Sum() interface{} { 119 | var r int 120 | s.Each(func(v int) { 121 | r += v 122 | }) 123 | return r 124 | } 125 | 126 | func (s iset) Product() interface{} { 127 | r := int(1) 128 | s.Each(func(v int) { 129 | r *= v 130 | }) 131 | return r 132 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/int8.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type i8map map[int8] bool 8 | 9 | func (m i8map) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m i8map) Member(i interface{}) (r bool) { 14 | if i, ok := i.(int8); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m i8map) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []int8: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case int8: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m i8map) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(int8): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | 51 | type i8set struct { 52 | i8map 53 | } 54 | 55 | func I8Set(v... int8) (r i8set) { 56 | r.i8map = make(i8map) 57 | r.Include(v) 58 | return 59 | } 60 | 61 | func (s i8set) Empty() Set { 62 | return I8Set() 63 | } 64 | 65 | func (s i8set) String() (t string) { 66 | elements := slices.I8Slice{} 67 | s.Each(func(v int8) { 68 | elements = append(elements, v) 69 | }) 70 | slices.Sort(elements) 71 | return elements.String() 72 | } 73 | 74 | func (s i8set) Intersection(o Set) Set { 75 | r := I8Set() 76 | s.Each(func(v int8) { 77 | if o.Member(v) { 78 | r.Include(v) 79 | } 80 | }) 81 | return r 82 | } 83 | 84 | func (s i8set) Union(o Set) Set { 85 | r := I8Set() 86 | s.Each(func(v int8) { 87 | r.Include(v) 88 | }) 89 | o.Each(func(v int8) { 90 | r.Include(v) 91 | }) 92 | return r 93 | } 94 | 95 | func (s i8set) Difference(o Set) Set { 96 | r := I8Set() 97 | s.Each(func(v int8) { 98 | if !o.Member(v) { 99 | r.Include(v) 100 | } 101 | }) 102 | return r 103 | } 104 | 105 | func (s i8set) Equal(o interface{}) (r bool) { 106 | if o, ok := o.(Set); ok { 107 | if r = s.Len() == o.Len(); r { 108 | s.Each(func(v int8) { 109 | if !o.Member(v) { 110 | r = false 111 | } 112 | }) 113 | } 114 | } 115 | return 116 | } 117 | 118 | func (s i8set) Sum() interface{} { 119 | var r int8 120 | s.Each(func(v int8) { 121 | r += v 122 | }) 123 | return r 124 | } 125 | 126 | func (s i8set) Product() interface{} { 127 | r := int8(1) 128 | s.Each(func(v int8) { 129 | r *= v 130 | }) 131 | return r 132 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/int_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestIString(t *testing.T) { 8 | ConfirmString := func(s iset, r string) { 9 | if v := s.String(); r != v { 10 | t.Errorf("String() expected %v but produced %v", r, v) 11 | } 12 | } 13 | 14 | ConfirmString(ISet(), "()") 15 | ConfirmString(ISet(0, 1), "(0 1)") 16 | ConfirmString(ISet(1, 0), "(0 1)") 17 | ConfirmString(ISet(0, 1, 2, 3, 4), "(0 1 2 3 4)") 18 | } 19 | 20 | func TestIMember(t *testing.T) { 21 | ConfirmMember := func(s iset, x int, r bool) { 22 | if v := s.Member(x); r != v { 23 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 24 | } 25 | } 26 | 27 | ConfirmMember(ISet(), 0, false) 28 | ConfirmMember(ISet(0), 0, true) 29 | ConfirmMember(ISet(0, 1), 0, true) 30 | ConfirmMember(ISet(0, 1), 1, true) 31 | ConfirmMember(ISet(0, 1), 2, false) 32 | } 33 | 34 | func TestIEqual(t *testing.T) { 35 | ConfirmEqual := func(s, x iset, r bool) { 36 | if v := s.Equal(x); r != v { 37 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 38 | } 39 | } 40 | 41 | ConfirmEqual(ISet(), ISet(), true) 42 | ConfirmEqual(ISet(0), ISet(), false) 43 | ConfirmEqual(ISet(), ISet(0), false) 44 | ConfirmEqual(ISet(0), ISet(0), true) 45 | ConfirmEqual(ISet(0, 0), ISet(0), true) 46 | ConfirmEqual(ISet(0), ISet(0, 0), true) 47 | ConfirmEqual(ISet(0, 1), ISet(0, 0), false) 48 | ConfirmEqual(ISet(0, 1), ISet(0, 1), true) 49 | ConfirmEqual(ISet(0, 1), ISet(1, 0), true) 50 | ConfirmEqual(ISet(0, 1), ISet(1, 1), false) 51 | } 52 | 53 | func TestISum(t *testing.T) { 54 | ConfirmSum := func(s iset, r int) { 55 | if v := s.Sum(); r != v { 56 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 57 | } 58 | } 59 | 60 | ConfirmSum(ISet(), 0) 61 | ConfirmSum(ISet(0), 0) 62 | ConfirmSum(ISet(0, 1), 1) 63 | ConfirmSum(ISet(0, 1, 1), 1) 64 | ConfirmSum(ISet(0, 1, 2), 3) 65 | } 66 | 67 | func TestIProduct(t *testing.T) { 68 | ConfirmProduct := func(s iset, r int) { 69 | if v := s.Product(); r != v { 70 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 71 | } 72 | } 73 | 74 | ConfirmProduct(ISet(), 1) 75 | ConfirmProduct(ISet(0), 0) 76 | ConfirmProduct(ISet(0, 1), 0) 77 | ConfirmProduct(ISet(1), 1) 78 | ConfirmProduct(ISet(1, 1), 1) 79 | ConfirmProduct(ISet(0, 1, 1), 0) 80 | ConfirmProduct(ISet(0, 1, 2), 0) 81 | ConfirmProduct(ISet(1, 2), 2) 82 | ConfirmProduct(ISet(1, 2, 3), 6) 83 | ConfirmProduct(ISet(1, 2, 3, 3), 6) 84 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/set.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type vmap map[interface{}] bool 8 | 9 | func (m vmap) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m vmap) Member(i interface{}) bool { 14 | return m[i] 15 | } 16 | 17 | func (m vmap) Include(v interface{}) { 18 | if x, ok := v.([]interface{}); ok { 19 | for i := len(x) - 1; i > -1; i-- { 20 | m[x[i]] = true 21 | } 22 | } else { 23 | m[v] = true 24 | } 25 | } 26 | 27 | func (m vmap) Each(f interface{}) { 28 | switch f := f.(type) { 29 | case func(interface{}): 30 | for k, v := range m { 31 | if v { 32 | f(k) 33 | } 34 | } 35 | } 36 | } 37 | 38 | func (m vmap) String() (t string) { 39 | elements := slices.Slice{} 40 | m.Each(func(v interface{}) { 41 | elements = append(elements, v) 42 | }) 43 | slices.Sort(elements) 44 | return elements.String() 45 | } 46 | 47 | 48 | type vset struct { 49 | vmap 50 | } 51 | 52 | func VSet(v... interface{}) (r vset) { 53 | r.vmap = make(vmap) 54 | r.Include(v) 55 | return 56 | } 57 | 58 | func (s vset) Empty() Set { 59 | return VSet() 60 | } 61 | 62 | func (s vset) Intersection(o Set) Set { 63 | r := VSet() 64 | s.Each(func(v interface{}) { 65 | if o.Member(v) { 66 | r.Include(v) 67 | } 68 | }) 69 | return r 70 | } 71 | 72 | func (s vset) Union(o Set) Set { 73 | r := VSet() 74 | s.Each(func(v interface{}) { 75 | r.Include(v) 76 | }) 77 | o.Each(func(v interface{}) { 78 | r.Include(v) 79 | }) 80 | return r 81 | } 82 | 83 | func (s vset) Difference(o Set) Set { 84 | r := VSet() 85 | s.Each(func(v interface{}) { 86 | if !o.Member(v) { 87 | r.Include(v) 88 | } 89 | }) 90 | return r 91 | } 92 | 93 | func (s vset) Equal(o interface{}) (r bool) { 94 | if o, ok := o.(Set); ok { 95 | if r = s.Len() == o.Len(); r { 96 | s.Each(func(v interface{}) { 97 | if !o.Member(v) { 98 | r = false 99 | } 100 | }) 101 | } 102 | } 103 | return 104 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/set_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestSetString(t *testing.T) { 8 | ConfirmString := func(s vset, r string) { 9 | if v := s.String(); r != v { 10 | t.Errorf("String() expected %v but produced %v", r, v) 11 | } 12 | } 13 | 14 | ConfirmString(VSet(), "()") 15 | // ConfirmString(VSet("A", "B"), "(A B)") 16 | // ConfirmString(VSet("B", "A"), "(A B)") 17 | // ConfirmString(VSet("A", "B", "C", "D", "E"), "(A B C D E)") 18 | } 19 | 20 | func TestSetMember(t *testing.T) { 21 | ConfirmMember := func(s vset, x string, r bool) { 22 | if v := s.Member(x); r != v { 23 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 24 | } 25 | } 26 | 27 | ConfirmMember(VSet(), "A", false) 28 | ConfirmMember(VSet("A"), "A", true) 29 | ConfirmMember(VSet("A", "B"), "A", true) 30 | ConfirmMember(VSet("A", "B"), "B", true) 31 | ConfirmMember(VSet("A", "B"), "C", false) 32 | } 33 | 34 | func TestSetEqual(t *testing.T) { 35 | ConfirmEqual := func(s, x vset, r bool) { 36 | if v := s.Equal(x); r != v { 37 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 38 | } 39 | } 40 | 41 | ConfirmEqual(VSet(), VSet(), true) 42 | ConfirmEqual(VSet("A"), VSet(), false) 43 | ConfirmEqual(VSet(), VSet("A"), false) 44 | ConfirmEqual(VSet("A"), VSet("A"), true) 45 | ConfirmEqual(VSet("A", "A"), VSet("A"), true) 46 | ConfirmEqual(VSet("A"), VSet("A", "A"), true) 47 | ConfirmEqual(VSet("A", "B"), VSet("A", "A"), false) 48 | ConfirmEqual(VSet("A", "B"), VSet("A", "B"), true) 49 | ConfirmEqual(VSet("A", "B"), VSet("B", "A"), true) 50 | ConfirmEqual(VSet("A", "B"), VSet("B", "B"), false) 51 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/sets.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | type Set interface { 4 | Len() int 5 | Empty() Set 6 | Include(interface{}) 7 | Member(interface{}) bool 8 | Each(interface{}) 9 | } 10 | 11 | type NumericSet interface { 12 | Set 13 | Sum() interface{} 14 | Product() interface{} 15 | } 16 | 17 | type Equatable interface { 18 | Equal(interface{}) bool 19 | } 20 | 21 | func SubsetOf(x, y Set) (r bool) { 22 | defer func() { 23 | recover() 24 | }() 25 | r = true 26 | x.Each(func(v interface{}) { 27 | if !y.Member(v) { 28 | r = false 29 | panic(r) 30 | } 31 | }) 32 | return 33 | } 34 | 35 | func Intersection(l, r Set) Set { 36 | n := l.Empty() 37 | l.Each(func(v interface{}) { 38 | if r.Member(v) { 39 | n.Include(v) 40 | } 41 | }) 42 | return n 43 | } 44 | 45 | func Union(l, r Set) Set { 46 | n := l.Empty() 47 | l.Each(func(v interface{}) { 48 | n.Include(v) 49 | }) 50 | r.Each(func(v interface{}) { 51 | n.Include(v) 52 | }) 53 | return n 54 | } 55 | 56 | func Difference(l, r Set) Set { 57 | n := l.Empty() 58 | l.Each(func(v interface{}) { 59 | if !r.Member(v) { 60 | n.Include(v) 61 | } 62 | }) 63 | return n 64 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/string.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type smap map[string] bool 8 | 9 | func (m smap) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m smap) Member(i interface{}) (r bool) { 14 | if i, ok := i.(string); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m smap) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []string: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case string: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m smap) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(string): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | 51 | type sset struct { 52 | smap 53 | } 54 | 55 | func SSet(v... string) (r sset) { 56 | r.smap = make(smap) 57 | r.Include(v) 58 | return 59 | } 60 | 61 | func (s sset) Empty() Set { 62 | return SSet() 63 | } 64 | 65 | func (s sset) String() (t string) { 66 | elements := slices.SSlice{} 67 | s.Each(func(v string) { 68 | elements = append(elements, v) 69 | }) 70 | slices.Sort(elements) 71 | return elements.String() 72 | } 73 | 74 | func (s sset) Intersection(o Set) Set { 75 | r := SSet() 76 | s.Each(func(v string) { 77 | if o.Member(v) { 78 | r.Include(v) 79 | } 80 | }) 81 | return r 82 | } 83 | 84 | func (s sset) Union(o Set) Set { 85 | r := SSet() 86 | s.Each(func(v string) { 87 | r.Include(v) 88 | }) 89 | o.Each(func(v string) { 90 | r.Include(v) 91 | }) 92 | return r 93 | } 94 | 95 | func (s sset) Difference(o Set) Set { 96 | r := SSet() 97 | s.Each(func(v string) { 98 | if !o.Member(v) { 99 | r.Include(v) 100 | } 101 | }) 102 | return r 103 | } 104 | 105 | func (s sset) Equal(o interface{}) (r bool) { 106 | if o, ok := o.(Set); ok { 107 | if r = s.Len() == o.Len(); r { 108 | s.Each(func(v string) { 109 | if !o.Member(v) { 110 | r = false 111 | } 112 | }) 113 | } 114 | } 115 | return 116 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/string_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestSString(t *testing.T) { 8 | ConfirmString := func(s sset, r string) { 9 | if v := s.String(); r != v { 10 | t.Errorf("String() expected %v but produced %v", r, v) 11 | } 12 | } 13 | 14 | ConfirmString(SSet(), "()") 15 | ConfirmString(SSet("A", "B"), "(A B)") 16 | ConfirmString(SSet("B", "A"), "(A B)") 17 | ConfirmString(SSet("A", "B", "C", "D", "E"), "(A B C D E)") 18 | } 19 | 20 | func TestSMember(t *testing.T) { 21 | ConfirmMember := func(s sset, x string, r bool) { 22 | if v := s.Member(x); r != v { 23 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 24 | } 25 | } 26 | 27 | ConfirmMember(SSet(), "A", false) 28 | ConfirmMember(SSet("A"), "A", true) 29 | ConfirmMember(SSet("A", "B"), "A", true) 30 | ConfirmMember(SSet("A", "B"), "B", true) 31 | ConfirmMember(SSet("A", "B"), "C", false) 32 | } 33 | 34 | func TestSEqual(t *testing.T) { 35 | ConfirmEqual := func(s, x sset, r bool) { 36 | if v := s.Equal(x); r != v { 37 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 38 | } 39 | } 40 | 41 | ConfirmEqual(SSet(), SSet(), true) 42 | ConfirmEqual(SSet("A"), SSet(), false) 43 | ConfirmEqual(SSet(), SSet("A"), false) 44 | ConfirmEqual(SSet("A"), SSet("A"), true) 45 | ConfirmEqual(SSet("A", "A"), SSet("A"), true) 46 | ConfirmEqual(SSet("A"), SSet("A", "A"), true) 47 | ConfirmEqual(SSet("A", "B"), SSet("A", "A"), false) 48 | ConfirmEqual(SSet("A", "B"), SSet("A", "B"), true) 49 | ConfirmEqual(SSet("A", "B"), SSet("B", "A"), true) 50 | ConfirmEqual(SSet("A", "B"), SSet("B", "B"), false) 51 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/uint.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "github.com/feyeleanor/slices" 5 | ) 6 | 7 | type umap map[uint] bool 8 | 9 | func (m umap) Len() int { 10 | return len(m) 11 | } 12 | 13 | func (m umap) Member(i interface{}) (r bool) { 14 | if i, ok := i.(uint); ok { 15 | r = m[i] 16 | } 17 | return 18 | } 19 | 20 | func (m umap) Include(v interface{}) { 21 | switch v := v.(type) { 22 | case []uint: 23 | for i := len(v) - 1; i > -1; i-- { 24 | m[v[i]] = true 25 | } 26 | case uint: 27 | m[v] = true 28 | default: 29 | panic(v) 30 | } 31 | } 32 | 33 | func (m umap) Each(f interface{}) { 34 | switch f := f.(type) { 35 | case func(uint): 36 | for k, v := range m { 37 | if v { 38 | f(k) 39 | } 40 | } 41 | case func(interface{}): 42 | for k, v := range m { 43 | if v { 44 | f(k) 45 | } 46 | } 47 | } 48 | } 49 | 50 | 51 | type uset struct { 52 | umap 53 | } 54 | 55 | func USet(v... uint) (r uset) { 56 | r.umap = make(umap) 57 | r.Include(v) 58 | return 59 | } 60 | 61 | func (s uset) Empty() Set { 62 | return USet() 63 | } 64 | 65 | func (s uset) String() (t string) { 66 | elements := slices.USlice{} 67 | s.Each(func(v uint) { 68 | elements = append(elements, v) 69 | }) 70 | slices.Sort(elements) 71 | return elements.String() 72 | } 73 | 74 | func (s uset) Intersection(o Set) Set { 75 | r := USet() 76 | s.Each(func(v uint) { 77 | if o.Member(v) { 78 | r.Include(v) 79 | } 80 | }) 81 | return r 82 | } 83 | 84 | func (s uset) Union(o Set) Set { 85 | r := USet() 86 | s.Each(func(v uint) { 87 | r.Include(v) 88 | }) 89 | o.Each(func(v uint) { 90 | r.Include(v) 91 | }) 92 | return r 93 | } 94 | 95 | func (s uset) Difference(o Set) Set { 96 | r := USet() 97 | s.Each(func(v uint) { 98 | if !o.Member(v) { 99 | r.Include(v) 100 | } 101 | }) 102 | return r 103 | } 104 | 105 | func (s uset) Equal(o interface{}) (r bool) { 106 | if o, ok := o.(Set); ok { 107 | if r = s.Len() == o.Len(); r { 108 | s.Each(func(v uint) { 109 | if !o.Member(v) { 110 | r = false 111 | } 112 | }) 113 | } 114 | } 115 | return 116 | } 117 | 118 | func (s uset) Sum() interface{} { 119 | var r uint 120 | s.Each(func(v uint) { 121 | r += v 122 | }) 123 | return r 124 | } 125 | 126 | func (s uset) Product() interface{} { 127 | r := uint(1) 128 | s.Each(func(v uint) { 129 | r *= v 130 | }) 131 | return r 132 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/uint_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestUString(t *testing.T) { 8 | ConfirmString := func(s uset, r string) { 9 | if v := s.String(); r != v { 10 | t.Errorf("String() expected %v but produced %v", r, v) 11 | } 12 | } 13 | 14 | ConfirmString(USet(), "()") 15 | ConfirmString(USet(0, 1), "(0 1)") 16 | ConfirmString(USet(1, 0), "(0 1)") 17 | ConfirmString(USet(0, 1, 2, 3, 4), "(0 1 2 3 4)") 18 | } 19 | 20 | func TestUMember(t *testing.T) { 21 | ConfirmMember := func(s uset, x uint, r bool) { 22 | if v := s.Member(x); r != v { 23 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 24 | } 25 | } 26 | 27 | ConfirmMember(USet(), 0, false) 28 | ConfirmMember(USet(0), 0, true) 29 | ConfirmMember(USet(0, 1), 0, true) 30 | ConfirmMember(USet(0, 1), 1, true) 31 | ConfirmMember(USet(0, 1), 2, false) 32 | } 33 | 34 | func TestUEqual(t *testing.T) { 35 | ConfirmEqual := func(s, x uset, r bool) { 36 | if v := s.Equal(x); r != v { 37 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 38 | } 39 | } 40 | 41 | ConfirmEqual(USet(), USet(), true) 42 | ConfirmEqual(USet(0), USet(), false) 43 | ConfirmEqual(USet(), USet(0), false) 44 | ConfirmEqual(USet(0), USet(0), true) 45 | ConfirmEqual(USet(0, 0), USet(0), true) 46 | ConfirmEqual(USet(0), USet(0, 0), true) 47 | ConfirmEqual(USet(0, 1), USet(0, 0), false) 48 | ConfirmEqual(USet(0, 1), USet(0, 1), true) 49 | ConfirmEqual(USet(0, 1), USet(1, 0), true) 50 | ConfirmEqual(USet(0, 1), USet(1, 1), false) 51 | } 52 | 53 | func TestUSum(t *testing.T) { 54 | ConfirmSum := func(s uset, r uint) { 55 | if v := s.Sum(); r != v { 56 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 57 | } 58 | } 59 | 60 | ConfirmSum(USet(), 0) 61 | ConfirmSum(USet(0), 0) 62 | ConfirmSum(USet(0, 1), 1) 63 | ConfirmSum(USet(0, 1, 1), 1) 64 | ConfirmSum(USet(0, 1, 2), 3) 65 | } 66 | 67 | func TestUProduct(t *testing.T) { 68 | ConfirmProduct := func(s uset, r uint) { 69 | if v := s.Product(); r != v { 70 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 71 | } 72 | } 73 | 74 | ConfirmProduct(USet(), 1) 75 | ConfirmProduct(USet(0), 0) 76 | ConfirmProduct(USet(0, 1), 0) 77 | ConfirmProduct(USet(1), 1) 78 | ConfirmProduct(USet(1, 1), 1) 79 | ConfirmProduct(USet(0, 1, 1), 0) 80 | ConfirmProduct(USet(0, 1, 2), 0) 81 | ConfirmProduct(USet(1, 2), 2) 82 | ConfirmProduct(USet(1, 2, 3), 6) 83 | ConfirmProduct(USet(1, 2, 3, 3), 6) 84 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/sets/uintptr_test.go: -------------------------------------------------------------------------------- 1 | package sets 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestAString(t *testing.T) { 8 | ConfirmString := func(s aset, r string) { 9 | if v := s.String(); r != v { 10 | t.Errorf("String() expected %v but produced %v", r, v) 11 | } 12 | } 13 | 14 | ConfirmString(ASet(), "()") 15 | ConfirmString(ASet(0, 1), "(0 1)") 16 | ConfirmString(ASet(1, 0), "(0 1)") 17 | ConfirmString(ASet(0, 1, 2, 3, 4), "(0 1 2 3 4)") 18 | } 19 | 20 | func TestAMember(t *testing.T) { 21 | ConfirmMember := func(s aset, x uintptr, r bool) { 22 | if v := s.Member(x); r != v { 23 | t.Errorf("%v.Member(%v) expected %v but produced %v", s, x, r, v) 24 | } 25 | } 26 | 27 | ConfirmMember(ASet(), 0, false) 28 | ConfirmMember(ASet(0), 0, true) 29 | ConfirmMember(ASet(0, 1), 0, true) 30 | ConfirmMember(ASet(0, 1), 1, true) 31 | ConfirmMember(ASet(0, 1), 2, false) 32 | } 33 | 34 | func TestAEqual(t *testing.T) { 35 | ConfirmEqual := func(s, x aset, r bool) { 36 | if v := s.Equal(x); r != v { 37 | t.Errorf("%v.Equal(%v) expected %v but produced %v", s, x, r, v) 38 | } 39 | } 40 | 41 | ConfirmEqual(ASet(), ASet(), true) 42 | ConfirmEqual(ASet(0), ASet(), false) 43 | ConfirmEqual(ASet(), ASet(0), false) 44 | ConfirmEqual(ASet(0), ASet(0), true) 45 | ConfirmEqual(ASet(0, 0), ASet(0), true) 46 | ConfirmEqual(ASet(0), ASet(0, 0), true) 47 | ConfirmEqual(ASet(0, 1), ASet(0, 0), false) 48 | ConfirmEqual(ASet(0, 1), ASet(0, 1), true) 49 | ConfirmEqual(ASet(0, 1), ASet(1, 0), true) 50 | ConfirmEqual(ASet(0, 1), ASet(1, 1), false) 51 | } 52 | 53 | func TestASum(t *testing.T) { 54 | ConfirmSum := func(s aset, r uintptr) { 55 | if v := s.Sum(); r != v { 56 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 57 | } 58 | } 59 | 60 | ConfirmSum(ASet(), 0) 61 | ConfirmSum(ASet(0), 0) 62 | ConfirmSum(ASet(0, 1), 1) 63 | ConfirmSum(ASet(0, 1, 1), 1) 64 | ConfirmSum(ASet(0, 1, 2), 3) 65 | } 66 | 67 | func TestAProduct(t *testing.T) { 68 | ConfirmProduct := func(s aset, r uintptr) { 69 | if v := s.Product(); r != v { 70 | t.Errorf("%v.Sum() expected %v but produced %v", s, r, v) 71 | } 72 | } 73 | 74 | ConfirmProduct(ASet(), 1) 75 | ConfirmProduct(ASet(0), 0) 76 | ConfirmProduct(ASet(0, 1), 0) 77 | ConfirmProduct(ASet(1), 1) 78 | ConfirmProduct(ASet(1, 1), 1) 79 | ConfirmProduct(ASet(0, 1, 1), 0) 80 | ConfirmProduct(ASet(0, 1, 2), 0) 81 | ConfirmProduct(ASet(1, 2), 2) 82 | ConfirmProduct(ASet(1, 2, 3), 6) 83 | ConfirmProduct(ASet(1, 2, 3, 3), 6) 84 | } -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/slices/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Eleanor McHugh 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | The Software shall be used for Good, not Evil. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/slices/README: -------------------------------------------------------------------------------- 1 | == About == 2 | 3 | The Slices package provides implementations of slice-based datatypes for all of Go's basic types, as well as two separate implementations for handling slices in the context of reflection values. Currently there's no documentation but the extensive test suite includes numerous examples of how to use slices to solve common tasks. 4 | 5 | The package has its origins in research for the GoLightly virtual machine project but has since taken on a life of its own. I hope you will find it useful. 6 | -------------------------------------------------------------------------------- /vendor/github.com/feyeleanor/slices/slices.go: -------------------------------------------------------------------------------- 1 | package slices 2 | 3 | import ( 4 | "math/rand" 5 | "reflect" 6 | "sort" 7 | ) 8 | 9 | const( 10 | IS_LESS_THAN = iota - 1 11 | IS_SAME_AS 12 | IS_GREATER_THAN 13 | ) 14 | 15 | type Nested interface { 16 | Depth() int 17 | } 18 | 19 | type Flattenable interface { 20 | Flatten() 21 | } 22 | 23 | type Equatable interface { 24 | Equal(interface{}) bool 25 | } 26 | 27 | type Typed interface { 28 | Type() reflect.Type 29 | } 30 | 31 | type Insertable interface { 32 | Len() int 33 | Insert(int, interface{}) 34 | } 35 | 36 | type Container interface { 37 | Len() int 38 | At(int) interface{} 39 | Set(int, interface{}) 40 | } 41 | 42 | type Deck interface { 43 | Len() int 44 | Swap(i, j int) 45 | } 46 | 47 | type Wipeable interface { 48 | Len() int 49 | BlockClear(int, int) 50 | } 51 | 52 | var( 53 | NESTED = reflect.TypeOf((*Nested)(nil)).Elem() 54 | FLATTENABLE = reflect.TypeOf((*Flattenable)(nil)).Elem() 55 | EQUATABLE = reflect.TypeOf((*Equatable)(nil)).Elem() 56 | TYPED = reflect.TypeOf((*Typed)(nil)).Elem() 57 | INSERTABLE = reflect.TypeOf((*Insertable)(nil)).Elem() 58 | CONTAINER = reflect.TypeOf((*Container)(nil)).Elem() 59 | ) 60 | 61 | func CanFlatten(s interface{}) (ok bool) { 62 | switch s := s.(type) { 63 | case reflect.Value: 64 | ok = s.Kind() == reflect.Slice || s.Type().Implements(FLATTENABLE) 65 | default: 66 | v := reflect.ValueOf(s) 67 | ok = v.Kind() == reflect.Slice || v.Type().Implements(FLATTENABLE) 68 | } 69 | return 70 | } 71 | 72 | func Prepend(i Insertable, value interface{}) { 73 | i.Insert(0, value) 74 | } 75 | 76 | func Append(i Insertable, value interface{}) { 77 | i.Insert(i.Len(), value) 78 | } 79 | 80 | func Shuffle(d Deck) { 81 | for i, v := range rand.Perm(d.Len()) { 82 | if v > i { 83 | d.Swap(i, v) 84 | } 85 | } 86 | } 87 | 88 | func ClearAll(i interface{}) (r bool) { 89 | if i, ok := i.(Wipeable); ok { 90 | i.BlockClear(0, i.Len()) 91 | r = true 92 | } 93 | return 94 | } 95 | 96 | func Equal(e, o interface{}) (r bool) { 97 | if e, ok := e.(Equatable); ok { 98 | r = e.Equal(o) 99 | } else if o, ok := o.(Equatable); ok { 100 | r = o.Equal(e) 101 | } 102 | return 103 | } 104 | 105 | func Sort(i interface{}) (r bool) { 106 | if i, ok := i.(sort.Interface); ok { 107 | sort.Sort(i) 108 | r = true 109 | } 110 | return 111 | } -------------------------------------------------------------------------------- /vendor/github.com/godbus/dbus/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | ## Getting Started 4 | 5 | - Fork the repository on GitHub 6 | - Read the [README](README.markdown) for build and test instructions 7 | - Play with the project, submit bugs, submit patches! 8 | 9 | ## Contribution Flow 10 | 11 | This is a rough outline of what a contributor's workflow looks like: 12 | 13 | - Create a topic branch from where you want to base your work (usually master). 14 | - Make commits of logical units. 15 | - Make sure your commit messages are in the proper format (see below). 16 | - Push your changes to a topic branch in your fork of the repository. 17 | - Make sure the tests pass, and add any new tests as appropriate. 18 | - Submit a pull request to the original repository. 19 | 20 | Thanks for your contributions! 21 | 22 | ### Format of the Commit Message 23 | 24 | We follow a rough convention for commit messages that is designed to answer two 25 | questions: what changed and why. The subject line should feature the what and 26 | the body of the commit should describe the why. 27 | 28 | ``` 29 | scripts: add the test-cluster command 30 | 31 | this uses tmux to setup a test cluster that you can easily kill and 32 | start for debugging. 33 | 34 | Fixes #38 35 | ``` 36 | 37 | The format can be described more formally as follows: 38 | 39 | ``` 40 | : 41 | 42 | 43 | 44 |