├── .evergreen.yml ├── .gitignore ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── THIRD-PARTY-NOTICES ├── archive ├── archive.go ├── demultiplexer.go ├── multiplexer.go ├── multiplexer_roundtrip_test.go ├── parser.go ├── parser_test.go ├── prelude.go └── prelude_test.go ├── auth └── auth_info.go ├── binaryurl.py ├── bsonutil ├── bsonutil.go ├── converter.go ├── converter_test.go ├── date_test.go ├── marshal_d.go ├── marshal_d_test.go ├── maxkey_test.go ├── minkey_test.go ├── number.go ├── numberint_test.go ├── numberlong_test.go ├── objectid_test.go ├── regexp_test.go ├── timestamp_test.go └── undefined_test.go ├── db ├── bson_stream.go ├── bson_stream_test.go ├── buffered_bulk.go ├── buffered_bulk_test.go ├── command.go ├── db.go ├── db_test.go ├── namespaces.go ├── namespaces_test.go ├── oplog.go ├── query.go ├── read_preferences.go ├── read_preferences_test.go ├── testdata │ ├── ca-ia.pem │ ├── ca.pem │ ├── server.pem │ ├── test-client.pem │ ├── test-server.pem │ └── testdata.bson ├── version.go ├── version_test.go ├── write_concern.go └── write_concern_test.go ├── etc └── generate-notices.pl ├── failpoint ├── failpoint.go ├── failpoint_disabled.go ├── failpoint_test.go └── failpoints.go ├── intents ├── intent.go ├── intent_prioritizer.go ├── intent_prioritizer_test.go └── intent_test.go ├── json ├── bench_test.go ├── bindata.go ├── bindata_test.go ├── boolean.go ├── boolean_test.go ├── constructor.go ├── consts.go ├── csv_format.go ├── date.go ├── date_test.go ├── dbpointer.go ├── dbpointer_test.go ├── dbref.go ├── dbref_test.go ├── decode.go ├── decode_d_test.go ├── decode_test.go ├── encode.go ├── encode_test.go ├── example_test.go ├── float_test.go ├── fold.go ├── fold_test.go ├── frac_test.go ├── helpers.go ├── hex.go ├── hex_test.go ├── indent.go ├── infinity.go ├── infinity_test.go ├── iso_date.go ├── iso_date_test.go ├── json_format.go ├── maxkey.go ├── maxkey_test.go ├── minkey.go ├── minkey_test.go ├── mongo_extjson.go ├── nan.go ├── nan_test.go ├── new.go ├── new_test.go ├── number.go ├── number_test.go ├── objectid.go ├── objectid_test.go ├── regexp.go ├── regexp_test.go ├── scanner.go ├── scanner_test.go ├── single_quoted.go ├── single_quoted_test.go ├── stream.go ├── stream_test.go ├── tagkey_test.go ├── tags.go ├── tags_test.go ├── testdata │ └── code.json.gz ├── timestamp.go ├── timestamp_test.go ├── undefined.go ├── undefined_test.go ├── unquoted.go └── unquoted_test.go ├── log ├── tool_logger.go └── tool_logger_test.go ├── options ├── options.go ├── options_fp.go ├── options_fp_disabled.go └── options_test.go ├── password ├── pass_util.go └── password.go ├── progress ├── manager.go ├── manager_test.go ├── progress_bar.go ├── progress_bar_test.go └── progressor.go ├── runLint.sh ├── runTests.sh ├── set_goenv.sh ├── signals └── signals.go ├── test.sh ├── testtype └── types.go ├── testutil ├── auth.go ├── kerberos.go ├── ssl_integration.go └── testutil.go ├── text ├── grid.go ├── grid_test.go ├── units.go └── units_test.go ├── txn ├── buffer.go ├── buffer_test.go ├── main_test.go ├── meta.go ├── meta_test.go └── testdata │ └── oplog_entries.json ├── util ├── bool.go ├── bool_test.go ├── exit_code.go ├── file.go ├── format_date.go ├── format_date_test.go ├── math.go ├── math_test.go ├── mongo.go ├── mongo_test.go ├── net.go ├── slice.go ├── strings.go ├── strings_test.go ├── timestamp.go ├── timestamp_test.go └── util.go └── vendor ├── github.com ├── go-stack │ └── stack │ │ ├── .travis.yml │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── go.mod │ │ └── stack.go ├── golang │ └── snappy │ │ ├── .gitignore │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── README │ │ ├── decode.go │ │ ├── decode_amd64.go │ │ ├── decode_amd64.s │ │ ├── decode_other.go │ │ ├── encode.go │ │ ├── encode_amd64.go │ │ ├── encode_amd64.s │ │ ├── encode_other.go │ │ ├── go.mod │ │ └── snappy.go ├── gopherjs │ └── gopherjs │ │ ├── LICENSE │ │ └── js │ │ └── js.go ├── jessevdk │ └── go-flags │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── arg.go │ │ ├── check_crosscompile.sh │ │ ├── closest.go │ │ ├── command.go │ │ ├── completion.go │ │ ├── convert.go │ │ ├── error.go │ │ ├── flags.go │ │ ├── group.go │ │ ├── help.go │ │ ├── ini.go │ │ ├── man.go │ │ ├── multitag.go │ │ ├── option.go │ │ ├── optstyle_other.go │ │ ├── optstyle_windows.go │ │ ├── parser.go │ │ ├── termsize.go │ │ ├── termsize_nosysioctl.go │ │ ├── tiocgwinsz_bsdish.go │ │ ├── tiocgwinsz_linux.go │ │ └── tiocgwinsz_other.go ├── jtolds │ └── gls │ │ ├── LICENSE │ │ ├── README.md │ │ ├── context.go │ │ ├── gen_sym.go │ │ ├── gid.go │ │ ├── id_pool.go │ │ ├── stack_tags.go │ │ ├── stack_tags_js.go │ │ └── stack_tags_main.go ├── smartystreets │ ├── assertions │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── collections.go │ │ ├── doc.go │ │ ├── equal_method.go │ │ ├── equality.go │ │ ├── equality_diff.go │ │ ├── filter.go │ │ ├── internal │ │ │ ├── go-diff │ │ │ │ ├── AUTHORS │ │ │ │ ├── CONTRIBUTORS │ │ │ │ ├── LICENSE │ │ │ │ └── diffmatchpatch │ │ │ │ │ ├── diff.go │ │ │ │ │ ├── diffmatchpatch.go │ │ │ │ │ ├── match.go │ │ │ │ │ ├── mathutil.go │ │ │ │ │ ├── operation_string.go │ │ │ │ │ ├── patch.go │ │ │ │ │ └── stringutil.go │ │ │ ├── go-render │ │ │ │ ├── LICENSE │ │ │ │ └── render │ │ │ │ │ ├── render.go │ │ │ │ │ └── render_time.go │ │ │ └── oglematchers │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── any_of.go │ │ │ │ ├── contains.go │ │ │ │ ├── deep_equals.go │ │ │ │ ├── equals.go │ │ │ │ ├── greater_or_equal.go │ │ │ │ ├── greater_than.go │ │ │ │ ├── less_or_equal.go │ │ │ │ ├── less_than.go │ │ │ │ ├── matcher.go │ │ │ │ ├── not.go │ │ │ │ └── transform_description.go │ │ ├── messages.go │ │ ├── panic.go │ │ ├── quantity.go │ │ ├── serializer.go │ │ ├── strings.go │ │ ├── time.go │ │ └── type.go │ └── goconvey │ │ ├── LICENSE.md │ │ ├── convey │ │ ├── assertions.go │ │ ├── context.go │ │ ├── convey.goconvey │ │ ├── discovery.go │ │ ├── doc.go │ │ ├── gotest │ │ │ └── utils.go │ │ ├── init.go │ │ ├── nilReporter.go │ │ └── reporting │ │ │ ├── console.go │ │ │ ├── doc.go │ │ │ ├── dot.go │ │ │ ├── gotest.go │ │ │ ├── init.go │ │ │ ├── json.go │ │ │ ├── printer.go │ │ │ ├── problems.go │ │ │ ├── reporter.go │ │ │ ├── reporting.goconvey │ │ │ ├── reports.go │ │ │ ├── statistics.go │ │ │ └── story.go │ │ └── web │ │ └── client │ │ └── resources │ │ └── fonts │ │ └── Open_Sans │ │ └── LICENSE.txt └── xdg │ ├── scram │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── client.go │ ├── client_conv.go │ ├── common.go │ ├── doc.go │ ├── parse.go │ ├── scram.go │ ├── server.go │ └── server_conv.go │ └── stringprep │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── bidi.go │ ├── doc.go │ ├── error.go │ ├── map.go │ ├── profile.go │ ├── saslprep.go │ ├── set.go │ └── tables.go ├── go.mongodb.org └── mongo-driver │ ├── LICENSE │ ├── THIRD-PARTY-NOTICES │ ├── bson │ ├── bson.go │ ├── bson_1_8.go │ ├── bsoncodec │ │ ├── bsoncodec.go │ │ ├── default_value_decoders.go │ │ ├── default_value_encoders.go │ │ ├── doc.go │ │ ├── mode.go │ │ ├── pointer_codec.go │ │ ├── proxy.go │ │ ├── registry.go │ │ ├── struct_codec.go │ │ ├── struct_tag_parser.go │ │ └── types.go │ ├── bsonrw │ │ ├── copier.go │ │ ├── doc.go │ │ ├── extjson_parser.go │ │ ├── extjson_reader.go │ │ ├── extjson_tables.go │ │ ├── extjson_wrappers.go │ │ ├── extjson_writer.go │ │ ├── json_scanner.go │ │ ├── mode.go │ │ ├── reader.go │ │ ├── value_reader.go │ │ ├── value_writer.go │ │ └── writer.go │ ├── bsontype │ │ └── bsontype.go │ ├── decoder.go │ ├── doc.go │ ├── encoder.go │ ├── marshal.go │ ├── primitive │ │ ├── decimal.go │ │ ├── objectid.go │ │ └── primitive.go │ ├── primitive_codecs.go │ ├── raw.go │ ├── raw_element.go │ ├── raw_value.go │ ├── registry.go │ ├── types.go │ └── unmarshal.go │ ├── etc │ └── generate-notices.pl │ ├── event │ └── monitoring.go │ ├── internal │ ├── const.go │ ├── error.go │ └── semaphore.go │ ├── mongo │ ├── batch_cursor.go │ ├── bulk_write.go │ ├── bulk_write_models.go │ ├── change_stream.go │ ├── client.go │ ├── collection.go │ ├── cursor.go │ ├── database.go │ ├── doc.go │ ├── errors.go │ ├── index_options_builder.go │ ├── index_view.go │ ├── mongo.go │ ├── options │ │ ├── aggregateoptions.go │ │ ├── bulkwriteoptions.go │ │ ├── changestreamoptions.go │ │ ├── clientoptions.go │ │ ├── clientoptions_1_10.go │ │ ├── clientoptions_1_9.go │ │ ├── collectionoptions.go │ │ ├── countoptions.go │ │ ├── dboptions.go │ │ ├── deleteoptions.go │ │ ├── distinctoptions.go │ │ ├── estimatedcountoptions.go │ │ ├── findoptions.go │ │ ├── gridfsoptions.go │ │ ├── indexoptions.go │ │ ├── insertoptions.go │ │ ├── listcollectionsoptions.go │ │ ├── listdatabasesoptions.go │ │ ├── mongooptions.go │ │ ├── replaceoptions.go │ │ ├── runcmdoptions.go │ │ ├── sessionoptions.go │ │ ├── transactionoptions.go │ │ └── updateoptions.go │ ├── readconcern │ │ └── readconcern.go │ ├── readpref │ │ ├── mode.go │ │ ├── options.go │ │ └── readpref.go │ ├── results.go │ ├── session.go │ ├── single_result.go │ ├── util.go │ └── writeconcern │ │ └── writeconcern.go │ ├── tag │ └── tag.go │ ├── version │ └── version.go │ └── x │ ├── bsonx │ ├── array.go │ ├── bsoncore │ │ ├── bsoncore.go │ │ ├── document.go │ │ ├── document_sequence.go │ │ ├── element.go │ │ ├── tables.go │ │ └── value.go │ ├── constructor.go │ ├── document.go │ ├── element.go │ ├── mdocument.go │ ├── primitive_codecs.go │ ├── registry.go │ └── value.go │ └── mongo │ └── driver │ ├── DESIGN.md │ ├── address │ └── addr.go │ ├── auth │ ├── auth.go │ ├── cred.go │ ├── default.go │ ├── doc.go │ ├── gssapi.go │ ├── gssapi_not_enabled.go │ ├── gssapi_not_supported.go │ ├── internal │ │ └── gssapi │ │ │ ├── gss.go │ │ │ ├── gss_wrapper.c │ │ │ ├── gss_wrapper.h │ │ │ ├── sspi.go │ │ │ ├── sspi_wrapper.c │ │ │ └── sspi_wrapper.h │ ├── mongodbcr.go │ ├── plain.go │ ├── sasl.go │ ├── scram.go │ ├── util.go │ └── x509.go │ ├── batch_cursor.go │ ├── batches.go │ ├── connstring │ └── connstring.go │ ├── description │ ├── description.go │ ├── feature.go │ ├── server.go │ ├── server_kind.go │ ├── server_selector.go │ ├── topology.go │ ├── topology_kind.go │ ├── version.go │ └── version_range.go │ ├── dns │ └── dns.go │ ├── driver.go │ ├── errors.go │ ├── legacy.go │ ├── list_collections_batch_cursor.go │ ├── operation.go │ ├── operation │ ├── abort_transaction.go │ ├── abort_transaction.toml │ ├── aggregate.go │ ├── aggregate.toml │ ├── command.go │ ├── commit_transaction.go │ ├── commit_transaction.toml │ ├── count.go │ ├── count.toml │ ├── createIndexes.go │ ├── createIndexes.toml │ ├── delete.go │ ├── delete.toml │ ├── distinct.go │ ├── distinct.toml │ ├── drop_collection.go │ ├── drop_collection.toml │ ├── drop_database.go │ ├── drop_database.toml │ ├── drop_indexes.go │ ├── drop_indexes.toml │ ├── end_sessions.go │ ├── end_sessions.toml │ ├── find.go │ ├── find.toml │ ├── find_and_modify.go │ ├── find_and_modify.toml │ ├── insert.go │ ├── insert.toml │ ├── ismaster.go │ ├── listDatabases.go │ ├── listDatabases.toml │ ├── list_collections.go │ ├── list_collections.toml │ ├── list_indexes.go │ ├── list_indexes.toml │ ├── operation.go │ ├── update.go │ └── update.toml │ ├── operation_legacy.go │ ├── session │ ├── client_session.go │ ├── cluster_clock.go │ ├── options.go │ ├── server_session.go │ └── session_pool.go │ ├── topology │ ├── DESIGN.md │ ├── connection.go │ ├── connection_legacy.go │ ├── connection_legacy_command_metadata.go │ ├── connection_options.go │ ├── errors.go │ ├── fsm.go │ ├── pool.go │ ├── resource_pool.go │ ├── server.go │ ├── server_options.go │ ├── topology.go │ ├── topology_options.go │ ├── topology_options_1_10.go │ └── topology_options_1_9.go │ ├── uuid │ └── uuid.go │ └── wiremessage │ └── wiremessage.go └── golang.org └── x ├── crypto ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── pbkdf2 │ └── pbkdf2.go └── ssh │ └── terminal │ ├── terminal.go │ ├── util.go │ ├── util_bsd.go │ ├── util_linux.go │ └── util_windows.go ├── sync ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS └── semaphore │ └── semaphore.go └── text ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── internal ├── gen │ ├── code.go │ └── gen.go ├── triegen │ ├── compact.go │ ├── print.go │ └── triegen.go └── ucd │ └── ucd.go ├── transform └── transform.go └── unicode ├── cldr ├── base.go ├── cldr.go ├── collate.go ├── decode.go ├── makexml.go ├── resolve.go ├── slice.go └── xml.go └── norm ├── composition.go ├── forminfo.go ├── input.go ├── iter.go ├── maketables.go ├── normalize.go ├── readwriter.go ├── tables10.0.0.go ├── tables11.0.0.go ├── tables9.0.0.go ├── transform.go ├── trie.go └── triegen.go /.gitignore: -------------------------------------------------------------------------------- 1 | *.bson 2 | *.dump 3 | *.exe 4 | *.json 5 | *.log 6 | *.out 7 | *.pcap 8 | *.playback 9 | *.pyc 10 | *.swp 11 | *.swp 12 | *.tape 13 | *.temp 14 | *.zip 15 | 16 | *temp* 17 | 18 | bin/ 19 | testing_output/ 20 | 21 | vendor/pkg 22 | 23 | .gopath 24 | .godeps 25 | .idea 26 | 27 | tags 28 | node_modules 29 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | [[constraint]] 28 | name = "go.mongodb.org/mongo-driver" 29 | version = "^v1.1.2" 30 | 31 | [[constraint]] 32 | name = "github.com/jessevdk/go-flags" 33 | version = "^v1.4.0" 34 | 35 | [[constraint]] 36 | name = "github.com/smartystreets/goconvey" 37 | revision = "bf58a9a1291224109919756b4dcc469c670cc7e4" 38 | 39 | [[constraint]] 40 | name = "golang.org/x/crypto" 41 | revision = "1f22c0103821b9390939b6776727195525381532" 42 | 43 | [prune] 44 | go-tests = true 45 | unused-packages = true 46 | 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 MongoDB, 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mongo-tools-common 2 | =================================== 3 | 4 | A collection of packages shared by the tools and mongomirror. 5 | 6 | **Note**: This project has been deprecated as of [TOOLS-2802](https://jira.mongodb.org/browse/TOOLS-2802) and currently supports only the [mongo-tools/v4.2](https://github.com/mongodb/mongo-tools/tree/v4.2) branch for critical changes. 7 | 8 | 9 | Using the mongo-tools-common packages 10 | --------------- 11 | 12 | To use the packages found here, use `mongo-tools` as a dependency instead. 13 | 14 | First, add a `mongo-tools` dependency with the desired commit hash or tag in your `go.mod` file: 15 | ``` 16 | require github.com/mongodb/mongo-tools 17 | ``` 18 | 19 | Then add the following import path with the desired subpackage in your Go file: 20 | ``` 21 | import "github.com/mongodb/mongo-tools/common/" 22 | ``` 23 | 24 | 25 | Making changes to mongo-tools/v4.2 26 | --------------- 27 | 28 | If a change to `mongo-tools/v4.2` requires changes to `mongo-tools-common`, make the changes and create a pull request to merge them to `mongo-tools-common/v4.2`. 29 | 30 | When merged, create a lightweight tag for `mongo-tools-common/v4.2` with appropriate minor/patch versions and push it: 31 | 32 | ``` 33 | git tag v2.X.x 34 | git push upstream tag v2.X.x 35 | ``` 36 | 37 | Then in the `Gopkg.toml` file for `mongo-tools/v4.2`, update the `mongo-tools-common` constraint: 38 | 39 | ``` 40 | [[constraint]] 41 | name = "github.com/mongodb/mongo-tools-common" 42 | version = "v2.X.x" 43 | ``` 44 | 45 | Finally, revendor the dependency in `mongo-tools/v4.2` using `dep`: 46 | ``` 47 | dep ensure -update github.com/mongodb/mongo-tools-common 48 | ``` 49 | -------------------------------------------------------------------------------- /archive/prelude_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package archive 8 | 9 | import ( 10 | "bytes" 11 | "testing" 12 | 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | ) 16 | 17 | func TestPrelude(t *testing.T) { 18 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 19 | 20 | var err error 21 | 22 | Convey("WritePrelude/ReadPrelude roundtrip", t, func() { 23 | 24 | cm1 := &CollectionMetadata{ 25 | Database: "db1", 26 | Collection: "c1", 27 | Metadata: "m1", 28 | } 29 | cm2 := &CollectionMetadata{ 30 | Database: "db1", 31 | Collection: "c2", 32 | Metadata: "m2", 33 | } 34 | cm3 := &CollectionMetadata{ 35 | Database: "db2", 36 | Collection: "c3", 37 | Metadata: "m3", 38 | } 39 | cm4 := &CollectionMetadata{ 40 | Database: "db3", 41 | Collection: "c4", 42 | Metadata: "m4", 43 | } 44 | 45 | archivePrelude := &Prelude{ 46 | Header: &Header{ 47 | FormatVersion: "version-foo", 48 | }, 49 | NamespaceMetadatas: []*CollectionMetadata{cm1, cm2, cm3, cm4}, 50 | DBS: []string{"db1", "db2", "db3"}, 51 | NamespaceMetadatasByDB: map[string][]*CollectionMetadata{ 52 | "db1": []*CollectionMetadata{cm1, cm2}, 53 | "db2": []*CollectionMetadata{cm3}, 54 | "db3": []*CollectionMetadata{cm4}, 55 | }, 56 | } 57 | buf := &bytes.Buffer{} 58 | err = archivePrelude.Write(buf) 59 | So(err, ShouldBeNil) 60 | archivePrelude2 := &Prelude{} 61 | err := archivePrelude2.Read(buf) 62 | So(err, ShouldBeNil) 63 | So(archivePrelude2, ShouldResemble, archivePrelude) 64 | }) 65 | } 66 | -------------------------------------------------------------------------------- /bsonutil/maxkey_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/primitive" 11 | "testing" 12 | 13 | "github.com/mongodb/mongo-tools-common/json" 14 | "github.com/mongodb/mongo-tools-common/testtype" 15 | . "github.com/smartystreets/goconvey/convey" 16 | ) 17 | 18 | func TestMaxKeyValue(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | Convey("When converting JSON with MaxKey values", t, func() { 22 | 23 | Convey("works for MaxKey literal", func() { 24 | key := "key" 25 | jsonMap := map[string]interface{}{ 26 | key: json.MaxKey{}, 27 | } 28 | 29 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 30 | So(err, ShouldBeNil) 31 | So(jsonMap[key], ShouldResemble, primitive.MaxKey{}) 32 | }) 33 | 34 | Convey(`works for MaxKey document ('{ "$maxKey": 1 }')`, func() { 35 | key := "maxKey" 36 | jsonMap := map[string]interface{}{ 37 | key: map[string]interface{}{ 38 | "$maxKey": 1, 39 | }, 40 | } 41 | 42 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 43 | So(err, ShouldBeNil) 44 | So(jsonMap[key], ShouldResemble, primitive.MaxKey{}) 45 | }) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /bsonutil/minkey_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | "go.mongodb.org/mongo-driver/bson/primitive" 16 | ) 17 | 18 | func TestMinKeyValue(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | Convey("When converting JSON with MinKey values", t, func() { 22 | 23 | Convey("works for MinKey literal", func() { 24 | key := "key" 25 | jsonMap := map[string]interface{}{ 26 | key: json.MinKey{}, 27 | } 28 | 29 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 30 | So(err, ShouldBeNil) 31 | So(jsonMap[key], ShouldResemble, primitive.MinKey{}) 32 | }) 33 | 34 | Convey(`works for MinKey document ('{ "$minKey": 1 }')`, func() { 35 | key := "key" 36 | jsonMap := map[string]interface{}{ 37 | key: map[string]interface{}{ 38 | "$minKey": 1, 39 | }, 40 | } 41 | 42 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 43 | So(err, ShouldBeNil) 44 | So(jsonMap[key], ShouldResemble, primitive.MinKey{}) 45 | }) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /bsonutil/number.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "fmt" 11 | "reflect" 12 | ) 13 | 14 | var floatType = reflect.TypeOf(float64(0)) 15 | 16 | func getFloat(unk interface{}) (float64, error) { 17 | v := reflect.ValueOf(unk) 18 | v = reflect.Indirect(v) 19 | if !v.Type().ConvertibleTo(floatType) { 20 | return 0, fmt.Errorf("cannot convert %v to float64", v.Type()) 21 | } 22 | fv := v.Convert(floatType) 23 | return fv.Float(), nil 24 | } 25 | -------------------------------------------------------------------------------- /bsonutil/numberint_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | ) 16 | 17 | func TestNumberIntValue(t *testing.T) { 18 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 19 | 20 | Convey("When converting JSON with NumberInt values", t, func() { 21 | 22 | Convey("works for NumberInt constructor", func() { 23 | key := "key" 24 | jsonMap := map[string]interface{}{ 25 | key: json.NumberInt(42), 26 | } 27 | 28 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 29 | So(err, ShouldBeNil) 30 | So(jsonMap[key], ShouldEqual, int32(42)) 31 | }) 32 | 33 | Convey(`works for NumberInt document ('{ "$numberInt": "42" }')`, func() { 34 | key := "key" 35 | jsonMap := map[string]interface{}{ 36 | key: map[string]interface{}{ 37 | "$numberInt": "42", 38 | }, 39 | } 40 | 41 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 42 | So(err, ShouldBeNil) 43 | So(jsonMap[key], ShouldEqual, int32(42)) 44 | }) 45 | }) 46 | } 47 | -------------------------------------------------------------------------------- /bsonutil/numberlong_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | ) 16 | 17 | func TestNumberLongValue(t *testing.T) { 18 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 19 | 20 | Convey("When converting JSON with NumberLong values", t, func() { 21 | 22 | Convey("works for NumberLong constructor", func() { 23 | key := "key" 24 | jsonMap := map[string]interface{}{ 25 | key: json.NumberLong(42), 26 | } 27 | 28 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 29 | So(err, ShouldBeNil) 30 | So(jsonMap[key], ShouldEqual, int64(42)) 31 | }) 32 | 33 | Convey(`works for NumberLong document ('{ "$numberLong": "42" }')`, func() { 34 | key := "key" 35 | jsonMap := map[string]interface{}{ 36 | key: map[string]interface{}{ 37 | "$numberLong": "42", 38 | }, 39 | } 40 | 41 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 42 | So(err, ShouldBeNil) 43 | So(jsonMap[key], ShouldEqual, int64(42)) 44 | }) 45 | }) 46 | } 47 | -------------------------------------------------------------------------------- /bsonutil/objectid_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | "go.mongodb.org/mongo-driver/bson/primitive" 16 | ) 17 | 18 | func TestObjectIdValue(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | oid, _ := primitive.ObjectIDFromHex("0123456789abcdef01234567") 21 | 22 | Convey("When converting JSON with ObjectId values", t, func() { 23 | 24 | Convey("works for ObjectId constructor", func() { 25 | key := "key" 26 | jsonMap := map[string]interface{}{ 27 | key: json.ObjectId("0123456789abcdef01234567"), 28 | } 29 | 30 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 31 | So(err, ShouldBeNil) 32 | So(jsonMap[key], ShouldEqual, oid) 33 | }) 34 | 35 | Convey(`works for ObjectId document ('{ "$oid": "0123456789abcdef01234567" }')`, func() { 36 | key := "key" 37 | jsonMap := map[string]interface{}{ 38 | key: map[string]interface{}{ 39 | "$oid": "0123456789abcdef01234567", 40 | }, 41 | } 42 | 43 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 44 | So(err, ShouldBeNil) 45 | So(jsonMap[key], ShouldEqual, oid) 46 | }) 47 | }) 48 | } 49 | -------------------------------------------------------------------------------- /bsonutil/timestamp_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | "go.mongodb.org/mongo-driver/bson/primitive" 16 | ) 17 | 18 | func TestTimestampValue(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | Convey("When converting JSON with Timestamp values", t, func() { 22 | testTS := primitive.Timestamp{T: 123456, I: 55} 23 | 24 | Convey("works for Timestamp literal", func() { 25 | 26 | jsonMap := map[string]interface{}{ 27 | "ts": json.Timestamp{123456, 55}, 28 | } 29 | 30 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 31 | So(err, ShouldBeNil) 32 | So(jsonMap["ts"], ShouldEqual, testTS) 33 | }) 34 | 35 | Convey(`works for Timestamp document`, func() { 36 | Convey(`{"ts":{"$timestamp":{"t":123456, "i":55}}}`, func() { 37 | jsonMap := map[string]interface{}{ 38 | "ts": map[string]interface{}{ 39 | "$timestamp": map[string]interface{}{ 40 | "t": 123456.0, 41 | "i": 55.0, 42 | }, 43 | }, 44 | } 45 | 46 | bsonMap, err := ConvertLegacyExtJSONValueToBSON(jsonMap) 47 | So(err, ShouldBeNil) 48 | So(bsonMap.(map[string]interface{})["ts"], ShouldEqual, testTS) 49 | }) 50 | }) 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /bsonutil/undefined_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonutil 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/json" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | "go.mongodb.org/mongo-driver/bson/primitive" 16 | ) 17 | 18 | func TestUndefinedValue(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | Convey("When converting JSON with undefined values", t, func() { 22 | 23 | Convey("works for undefined literal", func() { 24 | key := "key" 25 | jsonMap := map[string]interface{}{ 26 | key: json.Undefined{}, 27 | } 28 | 29 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 30 | So(err, ShouldBeNil) 31 | So(jsonMap[key], ShouldResemble, primitive.Undefined{}) 32 | }) 33 | 34 | Convey(`works for undefined document ('{ "$undefined": true }')`, func() { 35 | key := "key" 36 | jsonMap := map[string]interface{}{ 37 | key: map[string]interface{}{ 38 | "$undefined": true, 39 | }, 40 | } 41 | 42 | err := ConvertLegacyExtJSONDocumentToBSON(jsonMap) 43 | So(err, ShouldBeNil) 44 | So(jsonMap[key], ShouldResemble, primitive.Undefined{}) 45 | }) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /db/bson_stream_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package db 8 | 9 | import ( 10 | "bytes" 11 | "io/ioutil" 12 | "testing" 13 | 14 | "github.com/mongodb/mongo-tools-common/testtype" 15 | . "github.com/smartystreets/goconvey/convey" 16 | "go.mongodb.org/mongo-driver/bson" 17 | "go.mongodb.org/mongo-driver/bson/primitive" 18 | ) 19 | 20 | func TestBufferlessBSONSource(t *testing.T) { 21 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 22 | 23 | var testValues = []bson.M{ 24 | {"_": primitive.Binary{Subtype: 0x80, Data: []byte("apples")}}, 25 | {"_": primitive.Binary{Subtype: 0x80, Data: []byte("bananas")}}, 26 | {"_": primitive.Binary{Subtype: 0x80, Data: []byte("cherries")}}, 27 | } 28 | Convey("with a buffer containing several bson documents with binary fields", t, func() { 29 | writeBuf := bytes.NewBuffer(make([]byte, 0, 1024)) 30 | for _, tv := range testValues { 31 | data, err := bson.Marshal(&tv) 32 | So(err, ShouldBeNil) 33 | _, err = writeBuf.Write(data) 34 | So(err, ShouldBeNil) 35 | } 36 | Convey("that we parse correctly with a BufferlessBSONSource", func() { 37 | bsonSource := NewDecodedBSONSource( 38 | NewBufferlessBSONSource(ioutil.NopCloser(writeBuf))) 39 | docs := []bson.M{} 40 | count := 0 41 | doc := &bson.M{} 42 | for bsonSource.Next(doc) { 43 | count++ 44 | docs = append(docs, *doc) 45 | doc = &bson.M{} 46 | } 47 | So(bsonSource.Err(), ShouldBeNil) 48 | So(count, ShouldEqual, len(testValues)) 49 | So(docs, ShouldResemble, testValues) 50 | }) 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /db/namespaces_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package db 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | . "github.com/smartystreets/goconvey/convey" 15 | ) 16 | 17 | type stripDBFromNamespaceTestCase struct { 18 | inputNamespace string 19 | inputDBName string 20 | 21 | outputNamespace string 22 | outputError error 23 | } 24 | 25 | func TestStripDBFromNamespace(t *testing.T) { 26 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 27 | 28 | Convey("When testing StripDBFromNamespace with cases", t, func() { 29 | testCases := []stripDBFromNamespaceTestCase{ 30 | { 31 | inputNamespace: "database.col", 32 | inputDBName: "database", 33 | 34 | outputNamespace: "col", 35 | outputError: nil, 36 | }, 37 | { 38 | inputNamespace: "database2.col", 39 | inputDBName: "database", 40 | 41 | outputNamespace: "", 42 | outputError: fmt.Errorf("namespace 'database2.col' format is invalid - expected to start with 'database.'"), 43 | }, 44 | { 45 | inputNamespace: "database.col", 46 | inputDBName: "notAPrefix", 47 | 48 | outputNamespace: "", 49 | outputError: fmt.Errorf("namespace 'database.col' format is invalid - expected to start with 'notAPrefix.'"), 50 | }, 51 | } 52 | Convey("cases should match expected", func() { 53 | for _, tc := range testCases { 54 | resultNamespace, resultError := StripDBFromNamespace(tc.inputNamespace, tc.inputDBName) 55 | So(resultError, ShouldResemble, tc.outputError) 56 | So(resultNamespace, ShouldEqual, tc.outputNamespace) 57 | } 58 | }) 59 | }) 60 | 61 | } 62 | -------------------------------------------------------------------------------- /db/query.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "go.mongodb.org/mongo-driver/bson" 5 | "go.mongodb.org/mongo-driver/mongo" 6 | mopt "go.mongodb.org/mongo-driver/mongo/options" 7 | ) 8 | 9 | // DeferredQuery represents a deferred query 10 | type DeferredQuery struct { 11 | Coll *mongo.Collection 12 | Filter interface{} 13 | Hint interface{} 14 | LogReplay bool 15 | } 16 | 17 | // EstimatedDocumentCount issues a count command. 18 | func (q *DeferredQuery) EstimatedDocumentCount() (int, error) { 19 | opt := mopt.EstimatedDocumentCount() 20 | c, err := q.Coll.EstimatedDocumentCount(nil, opt) 21 | return int(c), err 22 | } 23 | 24 | // Iter executes a find query and returns a cursor. 25 | func (q *DeferredQuery) Iter() (*mongo.Cursor, error) { 26 | opts := mopt.Find() 27 | if q.Hint != nil { 28 | opts.SetHint(q.Hint) 29 | } 30 | if q.LogReplay { 31 | opts.SetOplogReplay(true) 32 | } 33 | filter := q.Filter 34 | if filter == nil { 35 | filter = bson.D{} 36 | } 37 | return q.Coll.Find(nil, filter, opts) 38 | } 39 | -------------------------------------------------------------------------------- /db/testdata/testdata.bson: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-tools-common/bde239e552e913e87bd26964fd795b09ed92016f/db/testdata/testdata.bson -------------------------------------------------------------------------------- /db/version.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | type Version [3]int 4 | 5 | func (v1 Version) Cmp(v2 Version) int { 6 | for i := range v1 { 7 | if v1[i] < v2[i] { 8 | return -1 9 | } 10 | if v1[i] > v2[i] { 11 | return 1 12 | } 13 | } 14 | return 0 15 | } 16 | 17 | func (v1 Version) LT(v2 Version) bool { 18 | return v1.Cmp(v2) == -1 19 | } 20 | 21 | func (v1 Version) LTE(v2 Version) bool { 22 | return v1.Cmp(v2) != 1 23 | } 24 | 25 | func (v1 Version) GT(v2 Version) bool { 26 | return v1.Cmp(v2) == 1 27 | } 28 | 29 | func (v1 Version) GTE(v2 Version) bool { 30 | return v1.Cmp(v2) != -1 31 | } 32 | -------------------------------------------------------------------------------- /failpoint/failpoint.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build failpoints 8 | 9 | // Package failpoint implements triggers for custom debugging behavoir 10 | package failpoint 11 | 12 | import ( 13 | "strings" 14 | ) 15 | 16 | var values map[string]string 17 | 18 | func init() { 19 | values = make(map[string]string) 20 | } 21 | 22 | // ParseFailpoints registers a comma-separated list of failpoint=value pairs 23 | func ParseFailpoints(arg string) { 24 | args := strings.Split(arg, ",") 25 | for _, fp := range args { 26 | if sep := strings.Index(fp, "="); sep != -1 { 27 | key := fp[:sep] 28 | val := fp[sep+1:] 29 | values[key] = val 30 | continue 31 | } 32 | values[fp] = "" 33 | } 34 | } 35 | 36 | // Get returns the value of the given failpoint and true, if it exists, and 37 | // false otherwise 38 | func Get(fp string) (string, bool) { 39 | val, ok := values[fp] 40 | return val, ok 41 | } 42 | 43 | // Enabled returns true iff the given failpoint has been turned on 44 | func Enabled(fp string) bool { 45 | _, ok := Get(fp) 46 | return ok 47 | } 48 | -------------------------------------------------------------------------------- /failpoint/failpoint_disabled.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build !failpoints 8 | 9 | package failpoint 10 | 11 | func ParseFailpoints(_ string) { 12 | } 13 | 14 | func Get(fp string) (string, bool) { 15 | return "", false 16 | } 17 | 18 | func Enabled(fp string) bool { 19 | return false 20 | } 21 | -------------------------------------------------------------------------------- /failpoint/failpoint_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build failpoints 8 | 9 | package failpoint 10 | 11 | import ( 12 | "testing" 13 | 14 | "github.com/mongodb/mongo-tools-common/testtype" 15 | . "github.com/smartystreets/goconvey/convey" 16 | ) 17 | 18 | func TestFailpointParsing(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | Convey("With test args", t, func() { 22 | args := "foo=bar,baz,biz=,=a" 23 | ParseFailpoints(args) 24 | 25 | So(Enabled("foo"), ShouldBeTrue) 26 | So(Enabled("baz"), ShouldBeTrue) 27 | So(Enabled("biz"), ShouldBeTrue) 28 | So(Enabled(""), ShouldBeTrue) 29 | So(Enabled("bar"), ShouldBeFalse) 30 | 31 | var val string 32 | var ok bool 33 | val, ok = Get("foo") 34 | So(val, ShouldEqual, "bar") 35 | So(ok, ShouldBeTrue) 36 | val, ok = Get("baz") 37 | So(val, ShouldEqual, "") 38 | So(ok, ShouldBeTrue) 39 | val, ok = Get("biz") 40 | So(val, ShouldEqual, "") 41 | So(ok, ShouldBeTrue) 42 | val, ok = Get("") 43 | So(val, ShouldEqual, "a") 44 | So(ok, ShouldBeTrue) 45 | val, ok = Get("bar") 46 | So(ok, ShouldBeFalse) 47 | }) 48 | } 49 | -------------------------------------------------------------------------------- /failpoint/failpoints.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package failpoint 8 | 9 | // Supported failpoint names 10 | const ( 11 | PauseBeforeDumping = "PauseBeforeDumping" 12 | SlowBSONDump = "SlowBSONDump" 13 | ) 14 | -------------------------------------------------------------------------------- /json/consts.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | const ( 10 | ArrayStart = '[' 11 | ArraySep = ',' 12 | ArrayEnd = ']' 13 | ) 14 | -------------------------------------------------------------------------------- /json/hex.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition function for recognizing hexadecimal numbers. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateHex is the state after reading `0x` or `0X`. 13 | func stateHex(s *scanner, c int) int { 14 | if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' { 15 | s.step = stateHex 16 | return scanContinue 17 | } 18 | return stateEndValue(s, c) 19 | } 20 | -------------------------------------------------------------------------------- /json/infinity.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition functions for recognizing Infinity. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateI is the state after reading `In`. 13 | func stateIn(s *scanner, c int) int { 14 | if c == 'f' { 15 | s.step = generateState("Infinity", []byte("inity"), stateEndValue) 16 | return scanContinue 17 | } 18 | return s.error(c, "in literal Infinity (expecting 'f')") 19 | } 20 | -------------------------------------------------------------------------------- /json/iso_date.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | import ( 10 | "fmt" 11 | "reflect" 12 | ) 13 | 14 | // Transition functions for recognizing ISODate. 15 | // Adapted from encoding/json/scanner.go. 16 | 17 | // stateIS is the state after reading `IS`. 18 | func stateIS(s *scanner, c int) int { 19 | if c == 'O' { 20 | s.step = stateISO 21 | return scanContinue 22 | } 23 | return s.error(c, "in literal ISODate (expecting 'O')") 24 | } 25 | 26 | // stateISO is the state after reading `ISO`. 27 | func stateISO(s *scanner, c int) int { 28 | if c == 'D' { 29 | s.step = stateD 30 | return scanContinue 31 | } 32 | return s.error(c, "in literal ISODate (expecting 'D')") 33 | } 34 | 35 | // Decodes a ISODate literal stored in the underlying byte data into v. 36 | func (d *decodeState) storeISODate(v reflect.Value) { 37 | op := d.scanWhile(scanSkipSpace) 38 | if op != scanBeginCtor { 39 | d.error(fmt.Errorf("expected beginning of constructor")) 40 | } 41 | args, err := d.ctor("ISODate", []reflect.Type{isoDateType}) 42 | if err != nil { 43 | d.error(err) 44 | } 45 | switch kind := v.Kind(); kind { 46 | case reflect.Interface: 47 | v.Set(args[0]) 48 | default: 49 | d.error(fmt.Errorf("cannot store %v value into %v type", isoDateType, kind)) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /json/maxkey.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition functions for recognizing MaxKey. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateUpperMa is the state after reading `Ma`. 13 | func stateUpperMa(s *scanner, c int) int { 14 | if c == 'x' { 15 | s.step = generateState("MaxKey", []byte("Key"), stateOptionalConstructor) 16 | return scanContinue 17 | } 18 | return s.error(c, "in literal MaxKey (expecting 'x')") 19 | } 20 | -------------------------------------------------------------------------------- /json/minkey.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition functions for recognizing MinKey. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateUpperMi is the state after reading `Mi`. 13 | func stateUpperMi(s *scanner, c int) int { 14 | if c == 'n' { 15 | s.step = generateState("MinKey", []byte("Key"), stateOptionalConstructor) 16 | return scanContinue 17 | } 18 | return s.error(c, "in literal MinKey (expecting 'n')") 19 | } 20 | -------------------------------------------------------------------------------- /json/nan.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition functions for recognizing NaN. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateUpperNa is the state after reading `Na`. 13 | func stateUpperNa(s *scanner, c int) int { 14 | if c == 'N' { 15 | s.step = stateEndValue 16 | return scanContinue 17 | } 18 | return s.error(c, "in literal NaN (expecting 'N')") 19 | } 20 | -------------------------------------------------------------------------------- /json/objectid.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | import ( 10 | "fmt" 11 | "reflect" 12 | ) 13 | 14 | // Transition functions for recognizing ObjectId. 15 | // Adapted from encoding/json/scanner.go. 16 | 17 | // stateO is the state after reading `O`. 18 | func stateO(s *scanner, c int) int { 19 | if c == 'b' { 20 | s.step = generateState("ObjectId", []byte("jectId"), stateConstructor) 21 | return scanContinue 22 | } 23 | return s.error(c, "in literal ObjectId (expecting 'b')") 24 | } 25 | 26 | // Decodes an ObjectId literal stored in the underlying byte data into v. 27 | func (d *decodeState) storeObjectId(v reflect.Value) { 28 | op := d.scanWhile(scanSkipSpace) 29 | if op != scanBeginCtor { 30 | d.error(fmt.Errorf("expected beginning of constructor")) 31 | } 32 | 33 | args, err := d.ctor("ObjectId", []reflect.Type{objectIdType}) 34 | if err != nil { 35 | d.error(err) 36 | } 37 | switch kind := v.Kind(); kind { 38 | case reflect.Interface: 39 | v.Set(args[0]) 40 | default: 41 | d.error(fmt.Errorf("cannot store %v value into %v type", objectIdType, kind)) 42 | } 43 | } 44 | 45 | // Returns an ObjectId literal from the underlying byte data. 46 | func (d *decodeState) getObjectId() interface{} { 47 | op := d.scanWhile(scanSkipSpace) 48 | if op != scanBeginCtor { 49 | d.error(fmt.Errorf("expected beginning of constructor")) 50 | } 51 | 52 | args := d.ctorInterface() 53 | if err := ctorNumArgsMismatch("ObjectId", 1, len(args)); err != nil { 54 | d.error(err) 55 | } 56 | arg0, ok := args[0].(string) 57 | if !ok { 58 | d.error(fmt.Errorf("expected string for first argument of ObjectId constructor")) 59 | } 60 | return ObjectId(arg0) 61 | } 62 | -------------------------------------------------------------------------------- /json/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | // 7 | // Based on github.com/golang/go by The Go Authors 8 | // See THIRD-PARTY-NOTICES for original license terms. 9 | 10 | package json 11 | 12 | import ( 13 | "strings" 14 | ) 15 | 16 | // tagOptions is the string following a comma in a struct field's "json" 17 | // tag, or the empty string. It does not include the leading comma. 18 | type tagOptions string 19 | 20 | // parseTag splits a struct field's json tag into its name and 21 | // comma-separated options. 22 | func parseTag(tag string) (string, tagOptions) { 23 | if idx := strings.Index(tag, ","); idx != -1 { 24 | return tag[:idx], tagOptions(tag[idx+1:]) 25 | } 26 | return tag, tagOptions("") 27 | } 28 | 29 | // Contains reports whether a comma-separated list of options 30 | // contains a particular substr flag. substr must be surrounded by a 31 | // string boundary or commas. 32 | func (o tagOptions) Contains(optionName string) bool { 33 | if len(o) == 0 { 34 | return false 35 | } 36 | s := string(o) 37 | for s != "" { 38 | var next string 39 | i := strings.Index(s, ",") 40 | if i >= 0 { 41 | s, next = s[:i], s[i+1:] 42 | } 43 | if s == optionName { 44 | return true 45 | } 46 | s = next 47 | } 48 | return false 49 | } 50 | -------------------------------------------------------------------------------- /json/tags_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | // 7 | // Based on github.com/golang/go by The Go Authors 8 | // See THIRD-PARTY-NOTICES for original license terms. 9 | 10 | package json 11 | 12 | import ( 13 | "testing" 14 | 15 | "github.com/mongodb/mongo-tools-common/testtype" 16 | ) 17 | 18 | func TestTagParsing(t *testing.T) { 19 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 20 | 21 | name, opts := parseTag("field,foobar,foo") 22 | if name != "field" { 23 | t.Fatalf("name = %q, want field", name) 24 | } 25 | for _, tt := range []struct { 26 | opt string 27 | want bool 28 | }{ 29 | {"foobar", true}, 30 | {"foo", true}, 31 | {"bar", false}, 32 | } { 33 | if opts.Contains(tt.opt) != tt.want { 34 | t.Errorf("Contains(%q) = %v", tt.opt, !tt.want) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /json/testdata/code.json.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-tools-common/bde239e552e913e87bd26964fd795b09ed92016f/json/testdata/code.json.gz -------------------------------------------------------------------------------- /json/undefined.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition functions for recognizing undefined. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | // stateU is the state after reading `u`. 13 | func stateU(s *scanner, c int) int { 14 | if c == 'n' { 15 | s.step = generateState("undefined", []byte("defined"), stateEndValue) 16 | return scanContinue 17 | } 18 | return s.error(c, "in literal undefined (expecting 'n')") 19 | } 20 | -------------------------------------------------------------------------------- /json/unquoted.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package json 8 | 9 | // Transition function for recognizing unquoted strings. 10 | // Adapted from encoding/json/scanner.go. 11 | 12 | func isBeginUnquotedString(c int) bool { 13 | return c == '$' || c == '_' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' 14 | } 15 | 16 | func isInUnquotedString(c int) bool { 17 | return isBeginUnquotedString(c) || '0' <= c && c <= '9' 18 | } 19 | 20 | func stateInUnquotedString(s *scanner, c int) int { 21 | if isInUnquotedString(c) { 22 | return scanContinue 23 | } 24 | return stateEndValue(s, c) 25 | } 26 | 27 | // Decoder function that immediately returns an already unquoted string. 28 | // Adapted from encoding/json/decode.go. 29 | func maybeUnquoteBytes(s []byte) ([]byte, bool) { 30 | if len(s) == 0 { 31 | return nil, false 32 | } 33 | if s[0] != '"' && s[len(s)-1] != '"' && s[0] != '\'' && s[len(s)-1] != '\'' { 34 | return s, true 35 | } 36 | return unquoteBytes(s) 37 | } 38 | -------------------------------------------------------------------------------- /options/options_fp.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build failpoints 8 | 9 | package options 10 | 11 | // EnableFailpoints does nothing if we've compiled with failpoints enabled 12 | func EnableFailpoints(opts *ToolOptions) { 13 | } 14 | -------------------------------------------------------------------------------- /options/options_fp_disabled.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build !failpoints 8 | 9 | package options 10 | 11 | // EnableFailpoints removes the failpoints options 12 | func EnableFailpoints(opts *ToolOptions) { 13 | opt := opts.FindOptionByLongName("failpoints") 14 | opt.LongName = "" 15 | } 16 | -------------------------------------------------------------------------------- /password/pass_util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // +build !solaris 8 | 9 | package password 10 | 11 | import ( 12 | "io" 13 | "os" 14 | "syscall" 15 | 16 | "golang.org/x/crypto/ssh/terminal" 17 | ) 18 | 19 | // This file contains all the calls needed to properly 20 | // handle password input from stdin/terminal on all 21 | // operating systems that aren't solaris 22 | 23 | func IsTerminal() bool { 24 | return terminal.IsTerminal(int(syscall.Stdin)) 25 | } 26 | 27 | func GetPass() (string, error) { 28 | oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) 29 | if err != nil { 30 | return "", err 31 | } 32 | defer terminal.Restore(int(os.Stdin.Fd()), oldState) 33 | 34 | screen := struct { 35 | io.Reader 36 | io.Writer 37 | }{os.Stdin, os.Stderr} 38 | 39 | t := terminal.NewTerminal(screen, "") 40 | pass, err := t.ReadPassword("") 41 | if err != nil { 42 | return "", err 43 | } 44 | return string(pass), nil 45 | } 46 | -------------------------------------------------------------------------------- /runLint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit 3 | 4 | golint $(go list ./... | sed -e 's!github.com/mongodb/mongo-tools-common!.!') \ 5 | | grep -v 'should have comment' \ 6 | | grep -v 'comment on exported' \ 7 | | grep -v 'Id.*should be.*ID' \ 8 | | perl -nle '$err = 1, print $_ if $_ } END { exit 1 if $err' 9 | 10 | GOLINT_RC="${PIPESTATUS[0]}" 11 | if [ $GOLINT_RC -ne 0 ]; then 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /runTests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tags="" 3 | if [ ! -z "$1" ] 4 | then 5 | tags="$@" 6 | fi 7 | 8 | # make sure we're in the directory where the script lives 9 | SCRIPT_DIR="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)" 10 | cd $SCRIPT_DIR 11 | OUTPUT_DIR="$SCRIPT_DIR/testing_output" 12 | mkdir -p "$OUTPUT_DIR" 13 | 14 | . ./set_goenv.sh 15 | set_goenv || exit 16 | 17 | # remove stale packages 18 | rm -rf vendor/pkg 19 | 20 | ec=0 21 | 22 | # Run all tests depending on what flags are set in the environment 23 | for i in $(find . -iname *.go | grep -v '^\./vendor/' | sed -e 's/\(.*\)\/.*\.go/\1/' | sort -u); do 24 | echo "Testing ${i}/..." 25 | COMMON_SUBPKG=$(basename $i) 26 | COVERAGE_ARGS=""; 27 | if [ "$RUN_COVERAGE" = "true" ]; then 28 | export COVERAGE_ARGS="-coverprofile=coverage_$COMMON_SUBPKG.out" 29 | fi 30 | if [ "$ON_EVERGREEN" = "true" ]; then 31 | (cd $i && go test "$(print_tags $tags)" "$COVERAGE_ARGS" > "$OUTPUT_DIR/$COMMON_SUBPKG.suite") 32 | exitcode=$? 33 | cat "$OUTPUT_DIR/$COMMON_SUBPKG.suite" 34 | # Evergreen looks for test files here 35 | cp "$OUTPUT_DIR/$COMMON_SUBPKG.suite" "$SCRIPT_DIR" 36 | else 37 | (cd $i && go test "$(print_tags $tags)" "$COVERAGE_ARGS" ) 38 | exitcode=$? 39 | fi 40 | if [ $exitcode -ne 0 ]; then 41 | echo "Error testing $i" 42 | ec=1 43 | fi 44 | done 45 | 46 | if [ -t /dev/stdin ]; then 47 | stty sane 48 | fi 49 | 50 | exit $ec 51 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tags="" 4 | if [ ! -z "$1" ] 5 | then 6 | tags="$@" 7 | fi 8 | 9 | # make sure we're in the directory where the script lives 10 | SCRIPT_DIR="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)" 11 | cd $SCRIPT_DIR 12 | 13 | export COVERAGE_ARGS="" 14 | 15 | export TOOLS_TESTING_UNIT="true" 16 | export TOOLS_TESTING_INTEGRATION="true" 17 | ./runTests.sh "$tags" 18 | ec=$? 19 | exit "$ec" 20 | -------------------------------------------------------------------------------- /testutil/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package testutil 8 | 9 | import ( 10 | "os" 11 | 12 | "github.com/mongodb/mongo-tools-common/options" 13 | "github.com/mongodb/mongo-tools-common/testtype" 14 | ) 15 | 16 | var ( 17 | UserAdmin = "uAdmin" 18 | UserAdminPassword = "password" 19 | CreatedUserNameEnv = "TOOLS_TESTING_AUTH_USERNAME" 20 | CreatedUserPasswordEnv = "TOOLS_TESTING_AUTH_PASSWORD" 21 | ) 22 | 23 | func GetAuthOptions() options.Auth { 24 | if testtype.HasTestType(testtype.AuthTestType) { 25 | return options.Auth{ 26 | Username: os.Getenv(CreatedUserNameEnv), 27 | Password: os.Getenv(CreatedUserPasswordEnv), 28 | Source: "admin", 29 | } 30 | } 31 | 32 | return options.Auth{} 33 | } 34 | 35 | func GetAuthArgs() []string { 36 | authOpts := GetAuthOptions() 37 | if authOpts.IsSet() { 38 | return []string { 39 | "--username", authOpts.Username, 40 | "--password", authOpts.Password, 41 | "--authenticationDatabase", authOpts.Source, 42 | } 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /testutil/kerberos.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package testutil 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "runtime" 13 | 14 | "github.com/mongodb/mongo-tools-common/options" 15 | ) 16 | 17 | var ( 18 | WinKerberosPwdEnv = "MONGODB_KERBEROS_PASSWORD" 19 | ) 20 | 21 | func GetKerberosOptions() (*options.ToolOptions, error) { 22 | opts := &options.ToolOptions{ 23 | Namespace: &options.Namespace{ 24 | DB: "kerberos", 25 | Collection: "test", 26 | }, 27 | SSL: &options.SSL{}, 28 | Auth: &options.Auth{ 29 | Username: "drivers@LDAPTEST.10GEN.CC", 30 | Source: "$external", 31 | Mechanism: "GSSAPI", 32 | }, 33 | Kerberos: &options.Kerberos{}, 34 | Connection: &options.Connection{ 35 | Host: "ldaptest.10gen.cc", 36 | Port: "27017", 37 | }, 38 | URI: &options.URI{}, 39 | } 40 | 41 | if runtime.GOOS == "windows" { 42 | opts.Auth.Password = os.Getenv(WinKerberosPwdEnv) 43 | if opts.Auth.Password == "" { 44 | return nil, fmt.Errorf("Need to set %v environment variable to run "+ 45 | "kerberos tests on windows", WinKerberosPwdEnv) 46 | } 47 | } 48 | 49 | return opts, nil 50 | } 51 | -------------------------------------------------------------------------------- /testutil/ssl_integration.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package testutil 8 | 9 | import ( 10 | commonOpts "github.com/mongodb/mongo-tools-common/options" 11 | "github.com/mongodb/mongo-tools-common/testtype" 12 | "runtime" 13 | "strings" 14 | ) 15 | 16 | func GetSSLArgs() []string { 17 | sslOpts := GetSSLOptions() 18 | if sslOpts.UseSSL { 19 | return []string{ 20 | "--ssl", 21 | "--sslCAFile", sslOpts.SSLCAFile, 22 | "--sslPEMKeyFile", sslOpts.SSLPEMKeyFile, 23 | } 24 | } 25 | return nil 26 | } 27 | 28 | func GetSSLOptions() commonOpts.SSL { 29 | // Get current filename and location 30 | _, filename, _, _ := runtime.Caller(0) 31 | // Get the path to containing folder 32 | foldername := filename[0:strings.LastIndex(filename, "/")] 33 | caFile := foldername + "/../db/testdata/ca-ia.pem" 34 | serverFile := foldername + "/../db/testdata/test-server.pem" 35 | if testtype.HasTestType(testtype.SSLTestType) { 36 | return commonOpts.SSL{ 37 | UseSSL: true, 38 | SSLCAFile: caFile, 39 | SSLPEMKeyFile: serverFile, 40 | } 41 | } 42 | 43 | return commonOpts.SSL{ 44 | UseSSL: false, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /util/bool.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/primitive" 11 | "reflect" 12 | ) 13 | 14 | // IsTruthy returns true for values the server will interpret as "true". 15 | // True values include {}, [], "", true, and any numbers != 0 16 | func IsTruthy(val interface{}) bool { 17 | if val == nil { 18 | return false 19 | } 20 | if val == (primitive.Undefined{}) { 21 | return false 22 | } 23 | 24 | v := reflect.ValueOf(val) 25 | switch v.Kind() { 26 | case reflect.Map, reflect.Slice, reflect.Array, reflect.String, reflect.Struct: 27 | return true 28 | default: 29 | z := reflect.Zero(v.Type()) 30 | return v.Interface() != z.Interface() 31 | } 32 | } 33 | 34 | // IsFalsy returns true for values the server will interpret as "false". 35 | // False values include numbers == 0, false, and nil 36 | func IsFalsy(val interface{}) bool { 37 | return !IsTruthy(val) 38 | } 39 | -------------------------------------------------------------------------------- /util/exit_code.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "errors" 11 | ) 12 | 13 | const ( 14 | ExitSuccess int = iota 15 | ExitFailure 16 | ) 17 | 18 | var ( 19 | ErrTerminated = errors.New("received termination signal") 20 | ) 21 | 22 | func ShortUsage(tool string) string { 23 | return "try '" + tool + " --help' for more information" 24 | } 25 | 26 | // SetupError is the error thrown by "New" functions used to convey what error occurred and the appropriate exit code. 27 | type SetupError struct { 28 | Err error 29 | 30 | // An optional message to be logged before exiting 31 | Message string 32 | } 33 | 34 | // Error implements the error interface. 35 | func (se SetupError) Error() string { 36 | return se.Err.Error() 37 | } 38 | -------------------------------------------------------------------------------- /util/format_date.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "time" 11 | ) 12 | 13 | var ( 14 | acceptedDateFormats = []string{ 15 | "2006-01-02T15:04:05.000Z", 16 | "2006-01-02T15:04:05Z", 17 | "2006-01-02T15:04Z", 18 | "2006-01-02T15:04:05.000-0700", 19 | "2006-01-02T15:04:05-0700", 20 | "2006-01-02T15:04-0700", 21 | "2006-01-02T15:04:05Z07:00", 22 | } 23 | ) 24 | 25 | func FormatDate(v string)(interface{}, error) { 26 | var date interface{} 27 | var err error 28 | 29 | for _, format := range acceptedDateFormats { 30 | date, err = time.Parse(format, v) 31 | if err == nil { 32 | return date, nil 33 | } 34 | } 35 | return date, err 36 | } 37 | -------------------------------------------------------------------------------- /util/format_date_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/mongodb/mongo-tools-common/testtype" 13 | . "github.com/smartystreets/goconvey/convey" 14 | ) 15 | 16 | func TestFormatDate(t *testing.T) { 17 | testtype.SkipUnlessTestType(t, testtype.UnitTestType) 18 | 19 | Convey("will take valid format 2006-01-02T15:04:05.000Z", t, func() { 20 | _, err := FormatDate("2014-01-02T15:04:05.000Z") 21 | So(err, ShouldBeNil) 22 | }) 23 | 24 | Convey("will take valid format 2006-01-02T15:04:05Z", t, func() { 25 | _, err := FormatDate("2014-03-02T15:05:05Z") 26 | So(err, ShouldBeNil) 27 | }) 28 | 29 | Convey("will take valid format 2006-01-02T15:04Z", t, func() { 30 | _, err := FormatDate("2014-04-02T15:04Z") 31 | So(err, ShouldBeNil) 32 | }) 33 | 34 | Convey("will take valid format 2006-01-02T15:04-0700", t, func() { 35 | _, err := FormatDate("2014-04-02T15:04-0800") 36 | So(err, ShouldBeNil) 37 | }) 38 | 39 | Convey("will take valid format 2006-01-02T15:04:05.000-0700", t, func() { 40 | _, err := FormatDate("2014-04-02T15:04:05.000-0600") 41 | So(err, ShouldBeNil) 42 | }) 43 | 44 | Convey("will take valid format 2006-01-02T15:04:05-0700", t, func() { 45 | _, err := FormatDate("2014-04-02T15:04:05-0500") 46 | So(err, ShouldBeNil) 47 | }) 48 | 49 | Convey("will return an error for an invalid format", t, func() { 50 | _, err := FormatDate("invalid string format") 51 | So(err, ShouldNotBeNil) 52 | }) 53 | 54 | } 55 | -------------------------------------------------------------------------------- /util/net.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "net" 11 | "time" 12 | ) 13 | 14 | // EnableTCPKeepAlive enables TCP keepalive on the underlying TCP connection. 15 | func EnableTCPKeepAlive(conn net.Conn, keepAlivePeriod time.Duration) error { 16 | if keepAlivePeriod == 0 { 17 | return nil 18 | } 19 | if tcpconn, ok := conn.(*net.TCPConn); ok { 20 | err := tcpconn.SetKeepAlive(true) 21 | if err != nil { 22 | return err 23 | } 24 | err = tcpconn.SetKeepAlivePeriod(keepAlivePeriod) 25 | if err != nil { 26 | return err 27 | } 28 | } 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /util/strings.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import "regexp" 10 | 11 | // Pluralize takes an amount and two strings denoting the singular 12 | // and plural noun the amount represents. If the amount is singular, 13 | // the singular form is returned; otherwise plural is returned. E.g. 14 | // Pluralize(X, "mouse", "mice") -> 0 mice, 1 mouse, 2 mice, ... 15 | func Pluralize(amount int, singular, plural string) string { 16 | if amount == 1 { 17 | return singular 18 | } 19 | return plural 20 | } 21 | 22 | var uriRedactionRE = regexp.MustCompile(`^([^:]+)://[^/?]*@`) 23 | 24 | func SanitizeURI(u string) string { 25 | return uriRedactionRE.ReplaceAllString(u, "$1://[**REDACTED**]@") 26 | } 27 | -------------------------------------------------------------------------------- /util/strings_test.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "testing" 4 | 5 | func TestSanitizeURI(t *testing.T) { 6 | cases := [][]string{ 7 | []string{"mongodb://example.com/", "mongodb://example.com/"}, 8 | []string{"mongodb://example.com/?appName=foo:@bar", "mongodb://example.com/?appName=foo:@bar"}, 9 | []string{"mongodb://example.com?appName=foo:@bar", "mongodb://example.com?appName=foo:@bar"}, 10 | []string{"mongodb://@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 11 | []string{"mongodb://:@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 12 | []string{"mongodb://user@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 13 | []string{"mongodb://user:@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 14 | []string{"mongodb://:pass@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 15 | []string{"mongodb://user:pass@example.com/", "mongodb://[**REDACTED**]@example.com/"}, 16 | []string{"mongodb+srv://example.com/", "mongodb+srv://example.com/"}, 17 | []string{"mongodb+srv://@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 18 | []string{"mongodb+srv://:@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 19 | []string{"mongodb+srv://user@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 20 | []string{"mongodb+srv://user:@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 21 | []string{"mongodb+srv://:pass@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 22 | []string{"mongodb+srv://user:pass@example.com/", "mongodb+srv://[**REDACTED**]@example.com/"}, 23 | } 24 | 25 | for _, c := range cases { 26 | got := SanitizeURI(c[0]) 27 | if got != c[1] { 28 | t.Errorf("For %s: got: %s; wanted: %s", c[0], got, c[1]) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /util/timestamp.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2019-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/primitive" 11 | ) 12 | 13 | // TimestampGreaterThan returns true if lhs comes after rhs, false otherwise. 14 | func TimestampGreaterThan(lhs, rhs primitive.Timestamp) bool { 15 | return lhs.T > rhs.T || lhs.T == rhs.T && lhs.I > rhs.I 16 | } 17 | 18 | // TimestampLessThan returns true if lhs comes before rhs, false otherwise. 19 | func TimestampLessThan(lhs, rhs primitive.Timestamp) bool { 20 | return lhs.T < rhs.T || lhs.T == rhs.T && lhs.I < rhs.I 21 | } 22 | -------------------------------------------------------------------------------- /util/timestamp_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2019-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package util 8 | 9 | import ( 10 | "testing" 11 | 12 | "go.mongodb.org/mongo-driver/bson/primitive" 13 | ) 14 | 15 | func TestTimestampComparisons(t *testing.T) { 16 | t.Run("TestTimestampGreaterThan", func(t *testing.T) { 17 | reference := primitive.Timestamp{T: 5, I: 5} 18 | 19 | cases := []struct { 20 | name string 21 | lhs, rhs primitive.Timestamp 22 | expected bool 23 | }{ 24 | {"different T", primitive.Timestamp{T: 1000, I: 0}, reference, true}, 25 | {"equal T", primitive.Timestamp{T: 5, I: 1}, reference, false}, 26 | {"equal T and I", reference, reference, false}, 27 | } 28 | 29 | for _, tc := range cases { 30 | t.Run(tc.name, func(t *testing.T) { 31 | if res := TimestampGreaterThan(tc.lhs, tc.rhs); res != tc.expected { 32 | t.Fatalf("comparison mismatch; expected %v, got %v", tc.expected, res) 33 | } 34 | }) 35 | } 36 | }) 37 | 38 | t.Run("TestTimestampGreaterThan", func(t *testing.T) { 39 | reference := primitive.Timestamp{T: 1000, I: 5} 40 | 41 | cases := []struct { 42 | name string 43 | lhs, rhs primitive.Timestamp 44 | expected bool 45 | }{ 46 | {"different T", primitive.Timestamp{T: 5, I: 0}, reference, true}, 47 | {"equal T", primitive.Timestamp{T: 1000, I: 10}, reference, false}, 48 | {"equal T and I", reference, reference, false}, 49 | } 50 | 51 | for _, tc := range cases { 52 | t.Run(tc.name, func(t *testing.T) { 53 | if res := TimestampLessThan(tc.lhs, tc.rhs); res != tc.expected { 54 | t.Fatalf("comparison mismatch; expected %v, got %v", tc.expected, res) 55 | } 56 | }) 57 | } 58 | }) 59 | } 60 | -------------------------------------------------------------------------------- /util/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2014-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package util provides commonly used utility functions. 8 | package util 9 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.7.x 5 | - 1.8.x 6 | - 1.9.x 7 | - 1.10.x 8 | - 1.11.x 9 | - tip 10 | 11 | before_install: 12 | - go get github.com/mattn/goveralls 13 | 14 | script: 15 | - goveralls -service=travis-ci 16 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chris Hines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack) 2 | [![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack) 3 | [![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master) 5 | 6 | # stack 7 | 8 | Package stack implements utilities to capture, manipulate, and format call 9 | stacks. It provides a simpler API than package runtime. 10 | 11 | The implementation takes care of the minutia and special cases of interpreting 12 | the program counter (pc) values returned by runtime.Callers. 13 | 14 | ## Versioning 15 | 16 | Package stack publishes releases via [semver](http://semver.org/) compatible Git 17 | tags prefixed with a single 'v'. The master branch always contains the latest 18 | release. The develop branch contains unreleased commits. 19 | 20 | ## Formatting 21 | 22 | Package stack's types implement fmt.Formatter, which provides a simple and 23 | flexible way to declaratively configure formatting when used with logging or 24 | error tracking packages. 25 | 26 | ```go 27 | func DoTheThing() { 28 | c := stack.Caller(0) 29 | log.Print(c) // "source.go:10" 30 | log.Printf("%+v", c) // "pkg/path/source.go:10" 31 | log.Printf("%n", c) // "DoTheThing" 32 | 33 | s := stack.Trace().TrimRuntime() 34 | log.Print(s) // "[source.go:15 caller.go:42 main.go:14]" 35 | } 36 | ``` 37 | 38 | See the docs for all of the supported formatting options. 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-stack/stack 2 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/.gitignore: -------------------------------------------------------------------------------- 1 | cmd/snappytool/snappytool 2 | testdata/bench 3 | 4 | # These explicitly listed benchmark data files are for an obsolete version of 5 | # snappy_test.go. 6 | testdata/alice29.txt 7 | testdata/asyoulik.txt 8 | testdata/fireworks.jpeg 9 | testdata/geo.protodata 10 | testdata/html 11 | testdata/html_x_4 12 | testdata/kppkn.gtb 13 | testdata/lcet10.txt 14 | testdata/paper-100k.pdf 15 | testdata/plrabn12.txt 16 | testdata/urls.10K 17 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Snappy-Go authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Damian Gryski 12 | Google Inc. 13 | Jan Mercl <0xjnml@gmail.com> 14 | Rodolfo Carvalho 15 | Sebastien Binet 16 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the Snappy-Go repository. 3 | # The AUTHORS file lists the copyright holders; this file 4 | # lists people. For example, Google employees are listed here 5 | # but not in AUTHORS, because Google holds the copyright. 6 | # 7 | # The submission process automatically checks to make sure 8 | # that people submitting code are listed in this file (by email address). 9 | # 10 | # Names should be added to this file only after verifying that 11 | # the individual or the individual's organization has agreed to 12 | # the appropriate Contributor License Agreement, found here: 13 | # 14 | # http://code.google.com/legal/individual-cla-v1.0.html 15 | # http://code.google.com/legal/corporate-cla-v1.0.html 16 | # 17 | # The agreement for individuals can be filled out on the web. 18 | # 19 | # When adding J Random Contributor's name to this file, 20 | # either J's name or J's organization's name should be 21 | # added to the AUTHORS file, depending on whether the 22 | # individual or corporate CLA was used. 23 | 24 | # Names should be added to this file like so: 25 | # Name 26 | 27 | # Please keep the list sorted. 28 | 29 | Damian Gryski 30 | Jan Mercl <0xjnml@gmail.com> 31 | Kai Backman 32 | Marc-Antoine Ruel 33 | Nigel Tao 34 | Rob Pike 35 | Rodolfo Carvalho 36 | Russ Cox 37 | Sebastien Binet 38 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 The Snappy-Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/decode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // decode has the same semantics as in decode_other.go. 12 | // 13 | //go:noescape 14 | func decode(dst, src []byte) int 15 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/encode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // emitLiteral has the same semantics as in encode_other.go. 12 | // 13 | //go:noescape 14 | func emitLiteral(dst, lit []byte) int 15 | 16 | // emitCopy has the same semantics as in encode_other.go. 17 | // 18 | //go:noescape 19 | func emitCopy(dst []byte, offset, length int) int 20 | 21 | // extendMatch has the same semantics as in encode_other.go. 22 | // 23 | //go:noescape 24 | func extendMatch(src []byte, i, j int) int 25 | 26 | // encodeBlock has the same semantics as in encode_other.go. 27 | // 28 | //go:noescape 29 | func encodeBlock(dst, src []byte) (d int) 30 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/golang/snappy 2 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Richard Musiol. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | go: 8 | - 1.x 9 | - 1.7.x 10 | - 1.8.x 11 | - 1.9.x 12 | - 1.10.x 13 | 14 | install: 15 | # go-flags 16 | - go get -d -v ./... 17 | - go build -v ./... 18 | 19 | # linting 20 | - go get github.com/golang/lint/golint 21 | 22 | # code coverage 23 | - go get golang.org/x/tools/cmd/cover 24 | - go get github.com/onsi/ginkgo/ginkgo 25 | - go get github.com/modocache/gover 26 | - if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then go get github.com/mattn/goveralls; fi 27 | 28 | script: 29 | # go-flags 30 | - $(exit $(gofmt -l . | wc -l)) 31 | - go test -v ./... 32 | 33 | # linting 34 | - go tool vet -all=true -v=true . || true 35 | - $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/golint ./... 36 | 37 | # code coverage 38 | - $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/ginkgo -r -cover 39 | - $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/gover 40 | - if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=gover.coverprofile -service=travis-ci -repotoken $COVERALLS_TOKEN; fi 41 | 42 | env: 43 | # coveralls.io 44 | secure: "RCYbiB4P0RjQRIoUx/vG/AjP3mmYCbzOmr86DCww1Z88yNcy3hYr3Cq8rpPtYU5v0g7wTpu4adaKIcqRE9xknYGbqj3YWZiCoBP1/n4Z+9sHW3Dsd9D/GRGeHUus0laJUGARjWoCTvoEtOgTdGQDoX7mH+pUUY0FBltNYUdOiiU=" 45 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Jesse van den Kieboom. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the 11 | distribution. 12 | * Neither the name of Google Inc. nor the names of its 13 | contributors may be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/arg.go: -------------------------------------------------------------------------------- 1 | package flags 2 | 3 | import ( 4 | "reflect" 5 | ) 6 | 7 | // Arg represents a positional argument on the command line. 8 | type Arg struct { 9 | // The name of the positional argument (used in the help) 10 | Name string 11 | 12 | // A description of the positional argument (used in the help) 13 | Description string 14 | 15 | // The minimal number of required positional arguments 16 | Required int 17 | 18 | // The maximum number of required positional arguments 19 | RequiredMaximum int 20 | 21 | value reflect.Value 22 | tag multiTag 23 | } 24 | 25 | func (a *Arg) isRemaining() bool { 26 | return a.value.Type().Kind() == reflect.Slice 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/check_crosscompile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo '# linux arm7' 6 | GOARM=7 GOARCH=arm GOOS=linux go build 7 | echo '# linux arm5' 8 | GOARM=5 GOARCH=arm GOOS=linux go build 9 | echo '# windows 386' 10 | GOARCH=386 GOOS=windows go build 11 | echo '# windows amd64' 12 | GOARCH=amd64 GOOS=windows go build 13 | echo '# darwin' 14 | GOARCH=amd64 GOOS=darwin go build 15 | echo '# freebsd' 16 | GOARCH=amd64 GOOS=freebsd go build 17 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/closest.go: -------------------------------------------------------------------------------- 1 | package flags 2 | 3 | func levenshtein(s string, t string) int { 4 | if len(s) == 0 { 5 | return len(t) 6 | } 7 | 8 | if len(t) == 0 { 9 | return len(s) 10 | } 11 | 12 | dists := make([][]int, len(s)+1) 13 | for i := range dists { 14 | dists[i] = make([]int, len(t)+1) 15 | dists[i][0] = i 16 | } 17 | 18 | for j := range t { 19 | dists[0][j] = j 20 | } 21 | 22 | for i, sc := range s { 23 | for j, tc := range t { 24 | if sc == tc { 25 | dists[i+1][j+1] = dists[i][j] 26 | } else { 27 | dists[i+1][j+1] = dists[i][j] + 1 28 | if dists[i+1][j] < dists[i+1][j+1] { 29 | dists[i+1][j+1] = dists[i+1][j] + 1 30 | } 31 | if dists[i][j+1] < dists[i+1][j+1] { 32 | dists[i+1][j+1] = dists[i][j+1] + 1 33 | } 34 | } 35 | } 36 | } 37 | 38 | return dists[len(s)][len(t)] 39 | } 40 | 41 | func closestChoice(cmd string, choices []string) (string, int) { 42 | if len(choices) == 0 { 43 | return "", 0 44 | } 45 | 46 | mincmd := -1 47 | mindist := -1 48 | 49 | for i, c := range choices { 50 | l := levenshtein(cmd, c) 51 | 52 | if mincmd < 0 || l < mindist { 53 | mindist = l 54 | mincmd = i 55 | } 56 | } 57 | 58 | return choices[mincmd], mindist 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/optstyle_other.go: -------------------------------------------------------------------------------- 1 | // +build !windows forceposix 2 | 3 | package flags 4 | 5 | import ( 6 | "strings" 7 | ) 8 | 9 | const ( 10 | defaultShortOptDelimiter = '-' 11 | defaultLongOptDelimiter = "--" 12 | defaultNameArgDelimiter = '=' 13 | ) 14 | 15 | func argumentStartsOption(arg string) bool { 16 | return len(arg) > 0 && arg[0] == '-' 17 | } 18 | 19 | func argumentIsOption(arg string) bool { 20 | if len(arg) > 1 && arg[0] == '-' && arg[1] != '-' { 21 | return true 22 | } 23 | 24 | if len(arg) > 2 && arg[0] == '-' && arg[1] == '-' && arg[2] != '-' { 25 | return true 26 | } 27 | 28 | return false 29 | } 30 | 31 | // stripOptionPrefix returns the option without the prefix and whether or 32 | // not the option is a long option or not. 33 | func stripOptionPrefix(optname string) (prefix string, name string, islong bool) { 34 | if strings.HasPrefix(optname, "--") { 35 | return "--", optname[2:], true 36 | } else if strings.HasPrefix(optname, "-") { 37 | return "-", optname[1:], false 38 | } 39 | 40 | return "", optname, false 41 | } 42 | 43 | // splitOption attempts to split the passed option into a name and an argument. 44 | // When there is no argument specified, nil will be returned for it. 45 | func splitOption(prefix string, option string, islong bool) (string, string, *string) { 46 | pos := strings.Index(option, "=") 47 | 48 | if (islong && pos >= 0) || (!islong && pos == 1) { 49 | rest := option[pos+1:] 50 | return option[:pos], "=", &rest 51 | } 52 | 53 | return option, "", nil 54 | } 55 | 56 | // addHelpGroup adds a new group that contains default help parameters. 57 | func (c *Command) addHelpGroup(showHelp func() error) *Group { 58 | var help struct { 59 | ShowHelp func() error `short:"h" long:"help" description:"Show this help message"` 60 | } 61 | 62 | help.ShowHelp = showHelp 63 | ret, _ := c.AddGroup("Help Options", "", &help) 64 | ret.isBuiltinHelp = true 65 | 66 | return ret 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/termsize.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!solaris,!appengine 2 | 3 | package flags 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | type winsize struct { 11 | row, col uint16 12 | xpixel, ypixel uint16 13 | } 14 | 15 | func getTerminalColumns() int { 16 | ws := winsize{} 17 | 18 | if tIOCGWINSZ != 0 { 19 | syscall.Syscall(syscall.SYS_IOCTL, 20 | uintptr(0), 21 | uintptr(tIOCGWINSZ), 22 | uintptr(unsafe.Pointer(&ws))) 23 | 24 | return int(ws.col) 25 | } 26 | 27 | return 80 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/termsize_nosysioctl.go: -------------------------------------------------------------------------------- 1 | // +build windows plan9 solaris appengine 2 | 3 | package flags 4 | 5 | func getTerminalColumns() int { 6 | return 80 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/tiocgwinsz_bsdish.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd 2 | 3 | package flags 4 | 5 | const ( 6 | tIOCGWINSZ = 0x40087468 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/tiocgwinsz_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package flags 4 | 5 | const ( 6 | tIOCGWINSZ = 0x5413 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/jessevdk/go-flags/tiocgwinsz_other.go: -------------------------------------------------------------------------------- 1 | // +build !darwin,!freebsd,!netbsd,!openbsd,!linux 2 | 3 | package flags 4 | 5 | const ( 6 | tIOCGWINSZ = 0 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Space Monkey, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gen_sym.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var ( 8 | keyMtx sync.Mutex 9 | keyCounter uint64 10 | ) 11 | 12 | // ContextKey is a throwaway value you can use as a key to a ContextManager 13 | type ContextKey struct{ id uint64 } 14 | 15 | // GenSym will return a brand new, never-before-used ContextKey 16 | func GenSym() ContextKey { 17 | keyMtx.Lock() 18 | defer keyMtx.Unlock() 19 | keyCounter += 1 20 | return ContextKey{id: keyCounter} 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gid.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | var ( 4 | stackTagPool = &idPool{} 5 | ) 6 | 7 | // Will return this goroutine's identifier if set. If you always need a 8 | // goroutine identifier, you should use EnsureGoroutineId which will make one 9 | // if there isn't one already. 10 | func GetGoroutineId() (gid uint, ok bool) { 11 | return readStackTag() 12 | } 13 | 14 | // Will call cb with the current goroutine identifier. If one hasn't already 15 | // been generated, one will be created and set first. The goroutine identifier 16 | // might be invalid after cb returns. 17 | func EnsureGoroutineId(cb func(gid uint)) { 18 | if gid, ok := readStackTag(); ok { 19 | cb(gid) 20 | return 21 | } 22 | gid := stackTagPool.Acquire() 23 | defer stackTagPool.Release(gid) 24 | addStackTag(gid, func() { cb(gid) }) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/id_pool.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // though this could probably be better at keeping ids smaller, the goal of 4 | // this class is to keep a registry of the smallest unique integer ids 5 | // per-process possible 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | type idPool struct { 12 | mtx sync.Mutex 13 | released []uint 14 | max_id uint 15 | } 16 | 17 | func (p *idPool) Acquire() (id uint) { 18 | p.mtx.Lock() 19 | defer p.mtx.Unlock() 20 | if len(p.released) > 0 { 21 | id = p.released[len(p.released)-1] 22 | p.released = p.released[:len(p.released)-1] 23 | return id 24 | } 25 | id = p.max_id 26 | p.max_id++ 27 | return id 28 | } 29 | 30 | func (p *idPool) Release(id uint) { 31 | p.mtx.Lock() 32 | defer p.mtx.Unlock() 33 | p.released = append(p.released, id) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package gls 4 | 5 | // This file is used for GopherJS builds, which don't have normal runtime 6 | // stack trace support 7 | 8 | import ( 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/gopherjs/gopherjs/js" 13 | ) 14 | 15 | const ( 16 | jsFuncNamePrefix = "github_com_jtolds_gls_mark" 17 | ) 18 | 19 | func jsMarkStack() (f []uintptr) { 20 | lines := strings.Split( 21 | js.Global.Get("Error").New().Get("stack").String(), "\n") 22 | f = make([]uintptr, 0, len(lines)) 23 | for i, line := range lines { 24 | line = strings.TrimSpace(line) 25 | if line == "" { 26 | continue 27 | } 28 | if i == 0 { 29 | if line != "Error" { 30 | panic("didn't understand js stack trace") 31 | } 32 | continue 33 | } 34 | fields := strings.Fields(line) 35 | if len(fields) < 2 || fields[0] != "at" { 36 | panic("didn't understand js stack trace") 37 | } 38 | 39 | pos := strings.Index(fields[1], jsFuncNamePrefix) 40 | if pos < 0 { 41 | continue 42 | } 43 | pos += len(jsFuncNamePrefix) 44 | if pos >= len(fields[1]) { 45 | panic("didn't understand js stack trace") 46 | } 47 | char := string(fields[1][pos]) 48 | switch char { 49 | case "S": 50 | f = append(f, uintptr(0)) 51 | default: 52 | val, err := strconv.ParseUint(char, 16, 8) 53 | if err != nil { 54 | panic("didn't understand js stack trace") 55 | } 56 | f = append(f, uintptr(val)+1) 57 | } 58 | } 59 | return f 60 | } 61 | 62 | // variables to prevent inlining 63 | var ( 64 | findPtr = func() uintptr { 65 | funcs := jsMarkStack() 66 | if len(funcs) == 0 { 67 | panic("failed to find function pointer") 68 | } 69 | return funcs[0] 70 | } 71 | 72 | getStack = func(offset, amount int) (stack []uintptr, next_offset int) { 73 | return jsMarkStack(), 0 74 | } 75 | ) 76 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_main.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package gls 4 | 5 | // This file is used for standard Go builds, which have the expected runtime 6 | // support 7 | 8 | import ( 9 | "runtime" 10 | ) 11 | 12 | var ( 13 | findPtr = func() uintptr { 14 | var pc [1]uintptr 15 | n := runtime.Callers(4, pc[:]) 16 | if n != 1 { 17 | panic("failed to find function pointer") 18 | } 19 | return pc[0] 20 | } 21 | 22 | getStack = func(offset, amount int) (stack []uintptr, next_offset int) { 23 | stack = make([]uintptr, amount) 24 | stack = stack[:runtime.Callers(offset, stack)] 25 | if len(stack) < amount { 26 | return stack, 0 27 | } 28 | return stack, offset + len(stack) 29 | } 30 | ) 31 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | *.iml 4 | /.idea 5 | coverage.out 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.x 5 | 6 | install: 7 | - go get -t ./... 8 | 9 | script: go test ./... -v 10 | 11 | sudo: false 12 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/equality_diff.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch" 7 | ) 8 | 9 | func composePrettyDiff(expected, actual string) string { 10 | diff := diffmatchpatch.New() 11 | diffs := diff.DiffMain(expected, actual, false) 12 | if prettyDiffIsLikelyToBeHelpful(diffs) { 13 | return fmt.Sprintf("\nDiff: '%s'", diff.DiffPrettyText(diffs)) 14 | } 15 | return "" 16 | } 17 | 18 | // prettyDiffIsLikelyToBeHelpful returns true if the diff listing contains 19 | // more 'equal' segments than 'deleted'/'inserted' segments. 20 | func prettyDiffIsLikelyToBeHelpful(diffs []diffmatchpatch.Diff) bool { 21 | equal, deleted, inserted := measureDiffTypeLengths(diffs) 22 | return equal > deleted && equal > inserted 23 | } 24 | 25 | func measureDiffTypeLengths(diffs []diffmatchpatch.Diff) (equal, deleted, inserted int) { 26 | for _, segment := range diffs { 27 | switch segment.Type { 28 | case diffmatchpatch.DiffEqual: 29 | equal += len(segment.Text) 30 | case diffmatchpatch.DiffDelete: 31 | deleted += len(segment.Text) 32 | case diffmatchpatch.DiffInsert: 33 | inserted += len(segment.Text) 34 | } 35 | } 36 | return equal, deleted, inserted 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/filter.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | const ( 6 | success = "" 7 | needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." 8 | needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." 9 | needFewerValues = "This assertion allows %d or fewer comparison values (you provided %d)." 10 | ) 11 | 12 | func need(needed int, expected []interface{}) string { 13 | if len(expected) != needed { 14 | return fmt.Sprintf(needExactValues, needed, len(expected)) 15 | } 16 | return success 17 | } 18 | 19 | func atLeast(minimum int, expected []interface{}) string { 20 | if len(expected) < minimum { 21 | return needNonEmptyCollection 22 | } 23 | return success 24 | } 25 | 26 | func atMost(max int, expected []interface{}) string { 27 | if len(expected) > max { 28 | return fmt.Sprintf(needFewerValues, max, len(expected)) 29 | } 30 | return success 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-diff/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of go-diff authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Danny Yoo 12 | James Kolb 13 | Jonathan Amsterdam 14 | Markus Zimmermann 15 | Matt Kovars 16 | Örjan Persson 17 | Osman Masood 18 | Robert Carlsen 19 | Rory Flynn 20 | Sergi Mansilla 21 | Shatrugna Sadhu 22 | Shawn Smith 23 | Stas Maksimov 24 | Tor Arvid Lund 25 | Zac Bergquist 26 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-diff/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the go-diff 3 | # repository. 4 | # 5 | # The AUTHORS file lists the copyright holders; this file 6 | # lists people. For example, ACME Inc. employees would be listed here 7 | # but not in AUTHORS, because ACME Inc. would hold the copyright. 8 | # 9 | # When adding J Random Contributor's name to this file, 10 | # either J's name or J's organization's name should be 11 | # added to the AUTHORS file. 12 | # 13 | # Names should be added to this file like so: 14 | # Name 15 | # 16 | # Please keep the list sorted. 17 | 18 | Danny Yoo 19 | James Kolb 20 | Jonathan Amsterdam 21 | Markus Zimmermann 22 | Matt Kovars 23 | Örjan Persson 24 | Osman Masood 25 | Robert Carlsen 26 | Rory Flynn 27 | Sergi Mansilla 28 | Shatrugna Sadhu 29 | Shawn Smith 30 | Stas Maksimov 31 | Tor Arvid Lund 32 | Zac Bergquist 33 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-diff/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2016 The go-diff Authors. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/mathutil.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2016 The go-diff authors. All rights reserved. 2 | // https://github.com/sergi/go-diff 3 | // See the included LICENSE file for license details. 4 | // 5 | // go-diff is a Go implementation of Google's Diff, Match, and Patch library 6 | // Original library is Copyright (c) 2006 Google Inc. 7 | // http://code.google.com/p/google-diff-match-patch/ 8 | 9 | package diffmatchpatch 10 | 11 | func min(x, y int) int { 12 | if x < y { 13 | return x 14 | } 15 | return y 16 | } 17 | 18 | func max(x, y int) int { 19 | if x > y { 20 | return x 21 | } 22 | return y 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/operation_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=Operation -trimprefix=Diff"; DO NOT EDIT. 2 | 3 | package diffmatchpatch 4 | 5 | import "fmt" 6 | 7 | const _Operation_name = "DeleteEqualInsert" 8 | 9 | var _Operation_index = [...]uint8{0, 6, 11, 17} 10 | 11 | func (i Operation) String() string { 12 | i -= -1 13 | if i < 0 || i >= Operation(len(_Operation_index)-1) { 14 | return fmt.Sprintf("Operation(%d)", i+-1) 15 | } 16 | return _Operation_name[_Operation_index[i]:_Operation_index[i+1]] 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/render/render_time.go: -------------------------------------------------------------------------------- 1 | package render 2 | 3 | import ( 4 | "reflect" 5 | "time" 6 | ) 7 | 8 | func renderTime(value reflect.Value) (string, bool) { 9 | if instant, ok := convertTime(value); !ok { 10 | return "", false 11 | } else if instant.IsZero() { 12 | return "0", true 13 | } else { 14 | return instant.String(), true 15 | } 16 | } 17 | 18 | func convertTime(value reflect.Value) (t time.Time, ok bool) { 19 | if value.Type() == timeType { 20 | defer func() { recover() }() 21 | t, ok = value.Interface().(time.Time) 22 | } 23 | return 24 | } 25 | 26 | var timeType = reflect.TypeOf(time.Time{}) 27 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 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 oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v >= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterOrEqual will panic. 30 | func GreaterOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than or equal to \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessThan(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 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 oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterThan returns a matcher that matches integer, floating point, or 24 | // strings values v such that v > x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterThan will panic. 30 | func GreaterThan(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessOrEqual(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 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 oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // LessOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v <= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // LessOrEqual will panic. 30 | func LessOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("less than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("less than or equal to \"%s\"", x) 36 | } 37 | 38 | // Put LessThan last so that its error messages will be used in the event of 39 | // failure. 40 | return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 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 oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | ) 22 | 23 | // Not returns a matcher that inverts the set of values matched by the wrapped 24 | // matcher. It does not transform the result for values for which the wrapped 25 | // matcher returns a fatal error. 26 | func Not(m Matcher) Matcher { 27 | return ¬Matcher{m} 28 | } 29 | 30 | type notMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *notMatcher) Matches(c interface{}) (err error) { 35 | err = m.wrapped.Matches(c) 36 | 37 | // Did the wrapped matcher say yes? 38 | if err == nil { 39 | return errors.New("") 40 | } 41 | 42 | // Did the wrapped matcher return a fatal error? 43 | if _, isFatal := err.(*FatalError); isFatal { 44 | return err 45 | } 46 | 47 | // The wrapped matcher returned a non-fatal error. 48 | return nil 49 | } 50 | 51 | func (m *notMatcher) Description() string { 52 | return fmt.Sprintf("not(%s)", m.wrapped.Description()) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 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 oglematchers 17 | 18 | // transformDescription returns a matcher that is equivalent to the supplied 19 | // one, except that it has the supplied description instead of the one attached 20 | // to the existing matcher. 21 | func transformDescription(m Matcher, newDesc string) Matcher { 22 | return &transformDescriptionMatcher{newDesc, m} 23 | } 24 | 25 | type transformDescriptionMatcher struct { 26 | desc string 27 | wrappedMatcher Matcher 28 | } 29 | 30 | func (m *transformDescriptionMatcher) Description() string { 31 | return m.desc 32 | } 33 | 34 | func (m *transformDescriptionMatcher) Matches(c interface{}) error { 35 | return m.wrappedMatcher.Matches(c) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/convey.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | #-covermode=count 4 | #-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go: -------------------------------------------------------------------------------- 1 | // Package gotest contains internal functionality. Although this package 2 | // contains one or more exported names it is not intended for public 3 | // consumption. See the examples package for how to use this project. 4 | package gotest 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | func ResolveExternalCaller() (file string, line int, name string) { 12 | var caller_id uintptr 13 | callers := runtime.Callers(0, callStack) 14 | 15 | for x := 0; x < callers; x++ { 16 | caller_id, file, line, _ = runtime.Caller(x) 17 | if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { 18 | name = runtime.FuncForPC(caller_id).Name() 19 | return 20 | } 21 | } 22 | file, line, name = "", -1, "" 23 | return // panic? 24 | } 25 | 26 | const maxStackDepth = 100 // This had better be enough... 27 | 28 | var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) 29 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/nilReporter.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "github.com/smartystreets/goconvey/convey/reporting" 5 | ) 6 | 7 | type nilReporter struct{} 8 | 9 | func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} 10 | func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} 11 | func (self *nilReporter) Report(report *reporting.AssertionResult) {} 12 | func (self *nilReporter) Exit() {} 13 | func (self *nilReporter) EndStory() {} 14 | func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } 15 | func newNilReporter() *nilReporter { return &nilReporter{} } 16 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/console.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type console struct{} 9 | 10 | func (self *console) Write(p []byte) (n int, err error) { 11 | return fmt.Print(string(p)) 12 | } 13 | 14 | func NewConsole() io.Writer { 15 | return new(console) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go: -------------------------------------------------------------------------------- 1 | // Package reporting contains internal functionality related 2 | // to console reporting and output. Although this package has 3 | // exported names is not intended for public consumption. See the 4 | // examples package for how to use this project. 5 | package reporting 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type dot struct{ out *Printer } 6 | 7 | func (self *dot) BeginStory(story *StoryReport) {} 8 | 9 | func (self *dot) Enter(scope *ScopeReport) {} 10 | 11 | func (self *dot) Report(report *AssertionResult) { 12 | if report.Error != nil { 13 | fmt.Print(redColor) 14 | self.out.Insert(dotError) 15 | } else if report.Failure != "" { 16 | fmt.Print(yellowColor) 17 | self.out.Insert(dotFailure) 18 | } else if report.Skipped { 19 | fmt.Print(yellowColor) 20 | self.out.Insert(dotSkip) 21 | } else { 22 | fmt.Print(greenColor) 23 | self.out.Insert(dotSuccess) 24 | } 25 | fmt.Print(resetColor) 26 | } 27 | 28 | func (self *dot) Exit() {} 29 | 30 | func (self *dot) EndStory() {} 31 | 32 | func (self *dot) Write(content []byte) (written int, err error) { 33 | return len(content), nil // no-op 34 | } 35 | 36 | func NewDotReporter(out *Printer) *dot { 37 | self := new(dot) 38 | self.out = out 39 | return self 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | type gotestReporter struct{ test T } 4 | 5 | func (self *gotestReporter) BeginStory(story *StoryReport) { 6 | self.test = story.Test 7 | } 8 | 9 | func (self *gotestReporter) Enter(scope *ScopeReport) {} 10 | 11 | func (self *gotestReporter) Report(r *AssertionResult) { 12 | if !passed(r) { 13 | self.test.Fail() 14 | } 15 | } 16 | 17 | func (self *gotestReporter) Exit() {} 18 | 19 | func (self *gotestReporter) EndStory() { 20 | self.test = nil 21 | } 22 | 23 | func (self *gotestReporter) Write(content []byte) (written int, err error) { 24 | return len(content), nil // no-op 25 | } 26 | 27 | func NewGoTestReporter() *gotestReporter { 28 | return new(gotestReporter) 29 | } 30 | 31 | func passed(r *AssertionResult) bool { 32 | return r.Error == nil && r.Failure == "" 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | type Printer struct { 10 | out io.Writer 11 | prefix string 12 | } 13 | 14 | func (self *Printer) Println(message string, values ...interface{}) { 15 | formatted := self.format(message, values...) + newline 16 | self.out.Write([]byte(formatted)) 17 | } 18 | 19 | func (self *Printer) Print(message string, values ...interface{}) { 20 | formatted := self.format(message, values...) 21 | self.out.Write([]byte(formatted)) 22 | } 23 | 24 | func (self *Printer) Insert(text string) { 25 | self.out.Write([]byte(text)) 26 | } 27 | 28 | func (self *Printer) format(message string, values ...interface{}) string { 29 | var formatted string 30 | if len(values) == 0 { 31 | formatted = self.prefix + message 32 | } else { 33 | formatted = self.prefix + fmt.Sprintf(message, values...) 34 | } 35 | indented := strings.Replace(formatted, newline, newline+self.prefix, -1) 36 | return strings.TrimRight(indented, space) 37 | } 38 | 39 | func (self *Printer) Indent() { 40 | self.prefix += pad 41 | } 42 | 43 | func (self *Printer) Dedent() { 44 | if len(self.prefix) >= padLength { 45 | self.prefix = self.prefix[:len(self.prefix)-padLength] 46 | } 47 | } 48 | 49 | func NewPrinter(out io.Writer) *Printer { 50 | self := new(Printer) 51 | self.out = out 52 | return self 53 | } 54 | 55 | const space = " " 56 | const pad = space + space 57 | const padLength = len(pad) 58 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "io" 4 | 5 | type Reporter interface { 6 | BeginStory(story *StoryReport) 7 | Enter(scope *ScopeReport) 8 | Report(r *AssertionResult) 9 | Exit() 10 | EndStory() 11 | io.Writer 12 | } 13 | 14 | type reporters struct{ collection []Reporter } 15 | 16 | func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } 17 | func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } 18 | func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } 19 | func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } 20 | func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } 21 | 22 | func (self *reporters) Write(contents []byte) (written int, err error) { 23 | self.foreach(func(r Reporter) { 24 | written, err = r.Write(contents) 25 | }) 26 | return written, err 27 | } 28 | 29 | func (self *reporters) foreach(action func(Reporter)) { 30 | for _, r := range self.collection { 31 | action(r) 32 | } 33 | } 34 | 35 | func NewReporters(collection ...Reporter) *reporters { 36 | self := new(reporters) 37 | self.collection = collection 38 | return self 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-tools-common/bde239e552e913e87bd26964fd795b09ed92016f/vendor/github.com/xdg/scram/.gitignore -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - "1.7" 5 | - "1.8" 6 | - "1.9" 7 | - "1.10" 8 | - master 9 | matrix: 10 | allow_failures: 11 | - go: master 12 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package scram provides client and server implementations of the Salted 8 | // Challenge Response Authentication Mechanism (SCRAM) described in RFC-5802 9 | // and RFC-7677. 10 | // 11 | // Usage 12 | // 13 | // The scram package provides two variables, `SHA1` and `SHA256`, that are 14 | // used to construct Client or Server objects. 15 | // 16 | // clientSHA1, err := scram.SHA1.NewClient(username, password, authID) 17 | // clientSHA256, err := scram.SHA256.NewClient(username, password, authID) 18 | // 19 | // serverSHA1, err := scram.SHA1.NewServer(credentialLookupFcn) 20 | // serverSHA256, err := scram.SHA256.NewServer(credentialLookupFcn) 21 | // 22 | // These objects are used to construct ClientConversation or 23 | // ServerConversation objects that are used to carry out authentication. 24 | package scram 25 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package scram 8 | 9 | import "sync" 10 | 11 | // Server implements the server side of SCRAM authentication. It holds 12 | // configuration values needed to initialize new server-side conversations. 13 | // Generally, this can be persistent within an application. 14 | type Server struct { 15 | sync.RWMutex 16 | credentialCB CredentialLookup 17 | nonceGen NonceGeneratorFcn 18 | hashGen HashGeneratorFcn 19 | } 20 | 21 | func newServer(cl CredentialLookup, fcn HashGeneratorFcn) (*Server, error) { 22 | return &Server{ 23 | credentialCB: cl, 24 | nonceGen: defaultNonceGenerator, 25 | hashGen: fcn, 26 | }, nil 27 | } 28 | 29 | // WithNonceGenerator replaces the default nonce generator (base64 encoding of 30 | // 24 bytes from crypto/rand) with a custom generator. This is provided for 31 | // testing or for users with custom nonce requirements. 32 | func (s *Server) WithNonceGenerator(ng NonceGeneratorFcn) *Server { 33 | s.Lock() 34 | defer s.Unlock() 35 | s.nonceGen = ng 36 | return s 37 | } 38 | 39 | // NewConversation constructs a server-side authentication conversation. 40 | // Conversations cannot be reused, so this must be called for each new 41 | // authentication attempt. 42 | func (s *Server) NewConversation() *ServerConversation { 43 | s.RLock() 44 | defer s.RUnlock() 45 | return &ServerConversation{ 46 | nonceGen: s.nonceGen, 47 | hashGen: s.hashGen, 48 | credentialCB: s.credentialCB, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-tools-common/bde239e552e913e87bd26964fd795b09ed92016f/vendor/github.com/xdg/stringprep/.gitignore -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - "1.7" 5 | - "1.8" 6 | - "1.9" 7 | - "1.10" 8 | - master 9 | matrix: 10 | allow_failures: 11 | - go: master 12 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/xdg/stringprep?status.svg)](https://godoc.org/github.com/xdg/stringprep) 2 | [![Build Status](https://travis-ci.org/xdg/stringprep.svg?branch=master)](https://travis-ci.org/xdg/stringprep) 3 | 4 | # stringprep – Go implementation of RFC-3454 stringprep and RFC-4013 SASLprep 5 | 6 | ## Synopsis 7 | 8 | ``` 9 | import "github.com/xdg/stringprep" 10 | 11 | prepped := stringprep.SASLprep.Prepare("TrustNô1") 12 | 13 | ``` 14 | 15 | ## Description 16 | 17 | This library provides an implementation of the stringprep algorithm 18 | (RFC-3454) in Go, including all data tables. 19 | 20 | A pre-built SASLprep (RFC-4013) profile is provided as well. 21 | 22 | ## Copyright and License 23 | 24 | Copyright 2018 by David A. Golden. All rights reserved. 25 | 26 | Licensed under the Apache License, Version 2.0 (the "License"). You may 27 | obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 28 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package stringprep provides data tables and algorithms for RFC-3454, 8 | // including errata (as of 2018-02). It also provides a profile for 9 | // SASLprep as defined in RFC-4013. 10 | package stringprep 11 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/error.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | import "fmt" 4 | 5 | // Error describes problems encountered during stringprep, including what rune 6 | // was problematic. 7 | type Error struct { 8 | Msg string 9 | Rune rune 10 | } 11 | 12 | func (e Error) Error() string { 13 | return fmt.Sprintf("%s (rune: '\\u%04x')", e.Msg, e.Rune) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/map.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package stringprep 8 | 9 | // Mapping represents a stringprep mapping, from a single rune to zero or more 10 | // runes. 11 | type Mapping map[rune][]rune 12 | 13 | // Map maps a rune to a (possibly empty) rune slice via a stringprep Mapping. 14 | // The ok return value is false if the rune was not found. 15 | func (m Mapping) Map(r rune) (replacement []rune, ok bool) { 16 | rs, ok := m[r] 17 | if !ok { 18 | return nil, false 19 | } 20 | return rs, true 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/profile.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | import ( 4 | "golang.org/x/text/unicode/norm" 5 | ) 6 | 7 | // Profile represents a stringprep profile. 8 | type Profile struct { 9 | Mappings []Mapping 10 | Normalize bool 11 | Prohibits []Set 12 | CheckBiDi bool 13 | } 14 | 15 | var errProhibited = "prohibited character" 16 | 17 | // Prepare transforms an input string to an output string following 18 | // the rules defined in the profile as defined by RFC-3454. 19 | func (p Profile) Prepare(s string) (string, error) { 20 | // Optimistically, assume output will be same length as input 21 | temp := make([]rune, 0, len(s)) 22 | 23 | // Apply maps 24 | for _, r := range s { 25 | rs, ok := p.applyMaps(r) 26 | if ok { 27 | temp = append(temp, rs...) 28 | } else { 29 | temp = append(temp, r) 30 | } 31 | } 32 | 33 | // Normalize 34 | var out string 35 | if p.Normalize { 36 | out = norm.NFKC.String(string(temp)) 37 | } else { 38 | out = string(temp) 39 | } 40 | 41 | // Check prohibited 42 | for _, r := range out { 43 | if p.runeIsProhibited(r) { 44 | return "", Error{Msg: errProhibited, Rune: r} 45 | } 46 | } 47 | 48 | // Check BiDi allowed 49 | if p.CheckBiDi { 50 | if err := passesBiDiRules(out); err != nil { 51 | return "", err 52 | } 53 | } 54 | 55 | return out, nil 56 | } 57 | 58 | func (p Profile) applyMaps(r rune) ([]rune, bool) { 59 | for _, m := range p.Mappings { 60 | rs, ok := m.Map(r) 61 | if ok { 62 | return rs, true 63 | } 64 | } 65 | return nil, false 66 | } 67 | 68 | func (p Profile) runeIsProhibited(r rune) bool { 69 | for _, s := range p.Prohibits { 70 | if s.Contains(r) { 71 | return true 72 | } 73 | } 74 | return false 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/saslprep.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | var mapNonASCIISpaceToASCIISpace = Mapping{ 4 | 0x00A0: []rune{0x0020}, 5 | 0x1680: []rune{0x0020}, 6 | 0x2000: []rune{0x0020}, 7 | 0x2001: []rune{0x0020}, 8 | 0x2002: []rune{0x0020}, 9 | 0x2003: []rune{0x0020}, 10 | 0x2004: []rune{0x0020}, 11 | 0x2005: []rune{0x0020}, 12 | 0x2006: []rune{0x0020}, 13 | 0x2007: []rune{0x0020}, 14 | 0x2008: []rune{0x0020}, 15 | 0x2009: []rune{0x0020}, 16 | 0x200A: []rune{0x0020}, 17 | 0x200B: []rune{0x0020}, 18 | 0x202F: []rune{0x0020}, 19 | 0x205F: []rune{0x0020}, 20 | 0x3000: []rune{0x0020}, 21 | } 22 | 23 | // SASLprep is a pre-defined stringprep profile for user names and passwords 24 | // as described in RFC-4013. 25 | // 26 | // Because the stringprep distinction between query and stored strings was 27 | // intended for compatibility across profile versions, but SASLprep was never 28 | // updated and is now deprecated, this profile only operates in stored 29 | // strings mode, prohibiting unassigned code points. 30 | var SASLprep Profile = saslprep 31 | 32 | var saslprep = Profile{ 33 | Mappings: []Mapping{ 34 | TableB1, 35 | mapNonASCIISpaceToASCIISpace, 36 | }, 37 | Normalize: true, 38 | Prohibits: []Set{ 39 | TableA1, 40 | TableC1_2, 41 | TableC2_1, 42 | TableC2_2, 43 | TableC3, 44 | TableC4, 45 | TableC5, 46 | TableC6, 47 | TableC7, 48 | TableC8, 49 | TableC9, 50 | }, 51 | CheckBiDi: true, 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package stringprep 8 | 9 | import "sort" 10 | 11 | // RuneRange represents a close-ended range of runes: [N,M]. For a range 12 | // consisting of a single rune, N and M will be equal. 13 | type RuneRange [2]rune 14 | 15 | // Contains returns true if a rune is within the bounds of the RuneRange. 16 | func (rr RuneRange) Contains(r rune) bool { 17 | return rr[0] <= r && r <= rr[1] 18 | } 19 | 20 | func (rr RuneRange) isAbove(r rune) bool { 21 | return r <= rr[0] 22 | } 23 | 24 | // Set represents a stringprep data table used to identify runes of a 25 | // particular type. 26 | type Set []RuneRange 27 | 28 | // Contains returns true if a rune is within any of the RuneRanges in the 29 | // Set. 30 | func (s Set) Contains(r rune) bool { 31 | i := sort.Search(len(s), func(i int) bool { return s[i].Contains(r) || s[i].isAbove(r) }) 32 | if i < len(s) && s[i].Contains(r) { 33 | return true 34 | } 35 | return false 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsoncodec 8 | 9 | import "fmt" 10 | 11 | type mode int 12 | 13 | const ( 14 | _ mode = iota 15 | mTopLevel 16 | mDocument 17 | mArray 18 | mValue 19 | mElement 20 | mCodeWithScope 21 | mSpacer 22 | ) 23 | 24 | func (m mode) String() string { 25 | var str string 26 | 27 | switch m { 28 | case mTopLevel: 29 | str = "TopLevel" 30 | case mDocument: 31 | str = "DocumentMode" 32 | case mArray: 33 | str = "ArrayMode" 34 | case mValue: 35 | str = "ValueMode" 36 | case mElement: 37 | str = "ElementMode" 38 | case mCodeWithScope: 39 | str = "CodeWithScopeMode" 40 | case mSpacer: 41 | str = "CodeWithScopeSpacerFrame" 42 | default: 43 | str = "UnknownMode" 44 | } 45 | 46 | return str 47 | } 48 | 49 | // TransitionError is an error returned when an invalid progressing a 50 | // ValueReader or ValueWriter state machine occurs. 51 | type TransitionError struct { 52 | parent mode 53 | current mode 54 | destination mode 55 | } 56 | 57 | func (te TransitionError) Error() string { 58 | if te.destination == mode(0) { 59 | return fmt.Sprintf("invalid state transition: cannot read/write value while in %s", te.current) 60 | } 61 | if te.parent == mode(0) { 62 | return fmt.Sprintf("invalid state transition: %s -> %s", te.current, te.destination) 63 | } 64 | return fmt.Sprintf("invalid state transition: %s -> %s; parent %s", te.current, te.destination, te.parent) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsoncodec 8 | 9 | // Proxy is an interface implemented by types that cannot themselves be directly encoded. Types 10 | // that implement this interface with have ProxyBSON called during the encoding process and that 11 | // value will be encoded in place for the implementer. 12 | type Proxy interface { 13 | ProxyBSON() (interface{}, error) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsonrw/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package bsonrw contains abstractions for reading and writing 8 | // BSON and BSON like types from sources. 9 | package bsonrw // import "go.mongodb.org/mongo-driver/bson/bsonrw" 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package bson is a library for reading, writing, and manipulating BSON. The 8 | // library has two families of types for representing BSON. 9 | // 10 | // The Raw family of types is used to validate and retrieve elements from a slice of bytes. This 11 | // type is most useful when you want do lookups on BSON bytes without unmarshaling it into another 12 | // type. 13 | // 14 | // Example: 15 | // var raw bson.Raw = ... // bytes from somewhere 16 | // err := raw.Validate() 17 | // if err != nil { return err } 18 | // val := raw.Lookup("foo") 19 | // i32, ok := val.Int32OK() 20 | // // do something with i32... 21 | // 22 | // The D family of types is used to build concise representations of BSON using native Go types. 23 | // These types do not support automatic lookup. 24 | // 25 | // Example: 26 | // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} 27 | // 28 | // 29 | // Marshaling and Unmarshaling are handled with the Marshal and Unmarshal family of functions. If 30 | // you need to write or read BSON from a non-slice source, an Encoder or Decoder can be used with a 31 | // bsonrw.ValueWriter or bsonrw.ValueReader. 32 | // 33 | // Example: 34 | // b, err := bson.Marshal(bson.D{{"foo", "bar"}}) 35 | // if err != nil { return err } 36 | // var fooer struct { 37 | // Foo string 38 | // } 39 | // err = bson.Unmarshal(b, &fooer) 40 | // if err != nil { return err } 41 | // // do something with fooer... 42 | package bson 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/registry.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bson 8 | 9 | import "go.mongodb.org/mongo-driver/bson/bsoncodec" 10 | 11 | // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the 12 | // primitive codecs. 13 | var DefaultRegistry = NewRegistryBuilder().Build() 14 | 15 | // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and 16 | // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the 17 | // PrimitiveCodecs type in this package. 18 | func NewRegistryBuilder() *bsoncodec.RegistryBuilder { 19 | rb := bsoncodec.NewRegistryBuilder() 20 | bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb) 21 | bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb) 22 | primitiveCodecs.RegisterPrimitiveCodecs(rb) 23 | return rb 24 | } 25 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/internal/const.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package internal // import "go.mongodb.org/mongo-driver/internal" 8 | 9 | // Version is the current version of the driver. 10 | var Version = "local build" 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/internal/semaphore.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package internal 8 | 9 | import ( 10 | "context" 11 | "errors" 12 | ) 13 | 14 | // NewSemaphore creates a new semaphore. 15 | func NewSemaphore(slots uint64) *Semaphore { 16 | ch := make(chan struct{}, slots) 17 | for i := uint64(0); i < slots; i++ { 18 | ch <- struct{}{} 19 | } 20 | 21 | return &Semaphore{ 22 | permits: ch, 23 | } 24 | } 25 | 26 | // Semaphore is a synchronization primitive that controls access 27 | // to a common resource. 28 | type Semaphore struct { 29 | permits chan struct{} 30 | } 31 | 32 | // Len gets the number of permits available. 33 | func (s *Semaphore) Len() uint64 { 34 | return uint64(len(s.permits)) 35 | } 36 | 37 | // Wait waits until a resource is available or until the context 38 | // is done. 39 | func (s *Semaphore) Wait(ctx context.Context) error { 40 | select { 41 | case <-s.permits: 42 | return nil 43 | case <-ctx.Done(): 44 | return ctx.Err() 45 | } 46 | } 47 | 48 | // Release releases a resource back into the pool. 49 | func (s *Semaphore) Release() error { 50 | select { 51 | case s.permits <- struct{}{}: 52 | default: 53 | return errors.New("internal.Semaphore.Release: attempt to release more resources than are available") 54 | } 55 | 56 | return nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/batch_cursor.go: -------------------------------------------------------------------------------- 1 | package mongo 2 | 3 | import ( 4 | "context" 5 | 6 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 7 | "go.mongodb.org/mongo-driver/x/mongo/driver" 8 | ) 9 | 10 | // batchCursor is the interface implemented by types that can provide batches of document results. 11 | // The Cursor type is built on top of this type. 12 | type batchCursor interface { 13 | // ID returns the ID of the cursor. 14 | ID() int64 15 | 16 | // Next returns true if there is a batch available. 17 | Next(context.Context) bool 18 | 19 | // Batch will return a DocumentSequence for the current batch of documents. The returned 20 | // DocumentSequence is only valid until the next call to Next or Close. 21 | Batch() *bsoncore.DocumentSequence 22 | 23 | // Server returns a pointer to the cursor's server. 24 | Server() driver.Server 25 | 26 | // Err returns the last error encountered. 27 | Err() error 28 | 29 | // Close closes the cursor. 30 | Close(context.Context) error 31 | } 32 | 33 | // changeStreamCursor is the interface implemented by batch cursors that also provide the functionality for retrieving 34 | // a postBatchResumeToken from commands and allows for the cursor to be killed rather than closed 35 | type changeStreamCursor interface { 36 | batchCursor 37 | // PostBatchResumeToken returns the latest seen post batch resume token. 38 | PostBatchResumeToken() bsoncore.Document 39 | 40 | // KillCursor kills cursor on server without closing batch cursor 41 | KillCursor(context.Context) error 42 | } 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions_1_10.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package options 4 | 5 | import "crypto/x509" 6 | 7 | func x509CertSubject(cert *x509.Certificate) string { 8 | return cert.Subject.String() 9 | } 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions_1_9.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package options 4 | 5 | import ( 6 | "crypto/x509" 7 | ) 8 | 9 | // We don't support version less then 1.10, but Evergreen needs to be able to compile the driver 10 | // using version 1.8. 11 | func x509CertSubject(cert *x509.Certificate) string { 12 | return "" 13 | } 14 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/deleteoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // DeleteOptions represents all possible options to the DeleteOne() and DeleteMany() functions. 10 | type DeleteOptions struct { 11 | Collation *Collation // Specifies a collation 12 | } 13 | 14 | // Delete returns a pointer to a new DeleteOptions 15 | func Delete() *DeleteOptions { 16 | return &DeleteOptions{} 17 | } 18 | 19 | // SetCollation specifies a collation 20 | // Valid for servers >= 3.4. 21 | func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions { 22 | do.Collation = c 23 | return do 24 | } 25 | 26 | // MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion 27 | func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions { 28 | dOpts := Delete() 29 | for _, do := range opts { 30 | if do == nil { 31 | continue 32 | } 33 | if do.Collation != nil { 34 | dOpts.Collation = do.Collation 35 | } 36 | } 37 | 38 | return dOpts 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/distinctoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "time" 10 | 11 | // DistinctOptions represents all possible options to the Distinct() function. 12 | type DistinctOptions struct { 13 | Collation *Collation // Specifies a collation 14 | MaxTime *time.Duration // The maximum amount of time to allow the operation to run 15 | } 16 | 17 | // Distinct returns a pointer to a new DistinctOptions 18 | func Distinct() *DistinctOptions { 19 | return &DistinctOptions{} 20 | } 21 | 22 | // SetCollation specifies a collation 23 | // Valid for server versions >= 3.4 24 | func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions { 25 | do.Collation = c 26 | return do 27 | } 28 | 29 | // SetMaxTime specifies the maximum amount of time to allow the operation to run 30 | func (do *DistinctOptions) SetMaxTime(d time.Duration) *DistinctOptions { 31 | do.MaxTime = &d 32 | return do 33 | } 34 | 35 | // MergeDistinctOptions combines the argued DistinctOptions into a single DistinctOptions in a last-one-wins fashion 36 | func MergeDistinctOptions(opts ...*DistinctOptions) *DistinctOptions { 37 | distinctOpts := Distinct() 38 | for _, do := range opts { 39 | if do == nil { 40 | continue 41 | } 42 | if do.Collation != nil { 43 | distinctOpts.Collation = do.Collation 44 | } 45 | if do.MaxTime != nil { 46 | distinctOpts.MaxTime = do.MaxTime 47 | } 48 | } 49 | 50 | return distinctOpts 51 | } 52 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/estimatedcountoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "time" 10 | 11 | // EstimatedDocumentCountOptions represents all possible options to the EstimatedDocumentCount() function. 12 | type EstimatedDocumentCountOptions struct { 13 | MaxTime *time.Duration // The maximum amount of time to allow the operation to run 14 | } 15 | 16 | // EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions 17 | func EstimatedDocumentCount() *EstimatedDocumentCountOptions { 18 | return &EstimatedDocumentCountOptions{} 19 | } 20 | 21 | // SetMaxTime specifies the maximum amount of time to allow the operation to run 22 | func (eco *EstimatedDocumentCountOptions) SetMaxTime(d time.Duration) *EstimatedDocumentCountOptions { 23 | eco.MaxTime = &d 24 | return eco 25 | } 26 | 27 | // MergeEstimatedDocumentCountOptions combines the given *EstimatedDocumentCountOptions into a single 28 | // *EstimatedDocumentCountOptions in a last one wins fashion. 29 | func MergeEstimatedDocumentCountOptions(opts ...*EstimatedDocumentCountOptions) *EstimatedDocumentCountOptions { 30 | e := EstimatedDocumentCount() 31 | for _, opt := range opts { 32 | if opt == nil { 33 | continue 34 | } 35 | 36 | if opt.MaxTime != nil { 37 | e.MaxTime = opt.MaxTime 38 | } 39 | } 40 | 41 | return e 42 | } 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/listcollectionsoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // ListCollectionsOptions represents all possible options for a listCollections command. 10 | type ListCollectionsOptions struct { 11 | NameOnly *bool // If true, only the collection names will be returned. 12 | } 13 | 14 | // ListCollections creates a new *ListCollectionsOptions 15 | func ListCollections() *ListCollectionsOptions { 16 | return &ListCollectionsOptions{} 17 | } 18 | 19 | // SetNameOnly specifies whether to return only the collection names. 20 | func (lc *ListCollectionsOptions) SetNameOnly(b bool) *ListCollectionsOptions { 21 | lc.NameOnly = &b 22 | return lc 23 | } 24 | 25 | // MergeListCollectionsOptions combines the given *ListCollectionsOptions into a single *ListCollectionsOptions in a 26 | // last one wins fashion. 27 | func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions { 28 | lc := ListCollections() 29 | for _, opt := range opts { 30 | if opt == nil { 31 | continue 32 | } 33 | if opt.NameOnly != nil { 34 | lc.NameOnly = opt.NameOnly 35 | } 36 | } 37 | 38 | return lc 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/listdatabasesoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // ListDatabasesOptions represents all possible options for a listDatabases command. 10 | type ListDatabasesOptions struct { 11 | NameOnly *bool // If true, only the database names will be returned. 12 | } 13 | 14 | // ListDatabases creates a new *ListDatabasesOptions 15 | func ListDatabases() *ListDatabasesOptions { 16 | return &ListDatabasesOptions{} 17 | } 18 | 19 | // SetNameOnly specifies whether to return only the database names. 20 | func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions { 21 | ld.NameOnly = &b 22 | return ld 23 | } 24 | 25 | // MergeListDatabasesOptions combines the given *ListDatabasesOptions into a single *ListDatabasesOptions in a last one 26 | // wins fashion. 27 | func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions { 28 | ld := ListDatabases() 29 | for _, opt := range opts { 30 | if opts == nil { 31 | continue 32 | } 33 | if opt.NameOnly != nil { 34 | ld.NameOnly = opt.NameOnly 35 | } 36 | } 37 | 38 | return ld 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/runcmdoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "go.mongodb.org/mongo-driver/mongo/readpref" 10 | 11 | // RunCmdOptions represents all possible options for a runCommand operation. 12 | type RunCmdOptions struct { 13 | ReadPreference *readpref.ReadPref // The read preference for the operation. 14 | } 15 | 16 | // RunCmd creates a new *RunCmdOptions 17 | func RunCmd() *RunCmdOptions { 18 | return &RunCmdOptions{} 19 | } 20 | 21 | // SetReadPreference sets the read preference for the operation. 22 | func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions { 23 | rc.ReadPreference = rp 24 | return rc 25 | } 26 | 27 | // MergeRunCmdOptions combines the given *RunCmdOptions into one *RunCmdOptions in a last one wins fashion. 28 | func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions { 29 | rc := RunCmd() 30 | for _, opt := range opts { 31 | if opt == nil { 32 | continue 33 | } 34 | if opt.ReadPreference != nil { 35 | rc.ReadPreference = opt.ReadPreference 36 | } 37 | } 38 | 39 | return rc 40 | } 41 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/readpref/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package readpref 8 | 9 | import ( 10 | "fmt" 11 | "strings" 12 | ) 13 | 14 | // Mode indicates the user's preference on reads. 15 | type Mode uint8 16 | 17 | // Mode constants 18 | const ( 19 | _ Mode = iota 20 | // PrimaryMode indicates that only a primary is 21 | // considered for reading. This is the default 22 | // mode. 23 | PrimaryMode 24 | // PrimaryPreferredMode indicates that if a primary 25 | // is available, use it; otherwise, eligible 26 | // secondaries will be considered. 27 | PrimaryPreferredMode 28 | // SecondaryMode indicates that only secondaries 29 | // should be considered. 30 | SecondaryMode 31 | // SecondaryPreferredMode indicates that only secondaries 32 | // should be considered when one is available. If none 33 | // are available, then a primary will be considered. 34 | SecondaryPreferredMode 35 | // NearestMode indicates that all primaries and secondaries 36 | // will be considered. 37 | NearestMode 38 | ) 39 | 40 | // ModeFromString returns a mode corresponding to 41 | // mode. 42 | func ModeFromString(mode string) (Mode, error) { 43 | switch strings.ToLower(mode) { 44 | case "primary": 45 | return PrimaryMode, nil 46 | case "primarypreferred": 47 | return PrimaryPreferredMode, nil 48 | case "secondary": 49 | return SecondaryMode, nil 50 | case "secondarypreferred": 51 | return SecondaryPreferredMode, nil 52 | case "nearest": 53 | return NearestMode, nil 54 | } 55 | return Mode(0), fmt.Errorf("unknown read preference %v", mode) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/readpref/options.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package readpref 8 | 9 | import ( 10 | "errors" 11 | "time" 12 | 13 | "go.mongodb.org/mongo-driver/tag" 14 | ) 15 | 16 | // ErrInvalidTagSet indicates that an invalid set of tags was specified. 17 | var ErrInvalidTagSet = errors.New("an even number of tags must be specified") 18 | 19 | // Option configures a read preference 20 | type Option func(*ReadPref) error 21 | 22 | // WithMaxStaleness sets the maximum staleness a 23 | // server is allowed. 24 | func WithMaxStaleness(ms time.Duration) Option { 25 | return func(rp *ReadPref) error { 26 | rp.maxStaleness = ms 27 | rp.maxStalenessSet = true 28 | return nil 29 | } 30 | } 31 | 32 | // WithTags sets a single tag set used to match 33 | // a server. The last call to WithTags or WithTagSets 34 | // overrides all previous calls to either method. 35 | func WithTags(tags ...string) Option { 36 | return func(rp *ReadPref) error { 37 | length := len(tags) 38 | if length < 2 || length%2 != 0 { 39 | return ErrInvalidTagSet 40 | } 41 | 42 | tagset := make(tag.Set, 0, length/2) 43 | 44 | for i := 1; i < length; i += 2 { 45 | tagset = append(tagset, tag.Tag{Name: tags[i-1], Value: tags[i]}) 46 | } 47 | 48 | return WithTagSets(tagset)(rp) 49 | } 50 | } 51 | 52 | // WithTagSets sets the tag sets used to match 53 | // a server. The last call to WithTags or WithTagSets 54 | // overrides all previous calls to either method. 55 | func WithTagSets(tagSets ...tag.Set) Option { 56 | return func(rp *ReadPref) error { 57 | rp.tagSets = tagSets 58 | return nil 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package mongo 8 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/tag/tag.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package tag // import "go.mongodb.org/mongo-driver/tag" 8 | 9 | // Tag is a name/vlaue pair. 10 | type Tag struct { 11 | Name string 12 | Value string 13 | } 14 | 15 | // NewTagSetFromMap creates a new tag set from a map. 16 | func NewTagSetFromMap(m map[string]string) Set { 17 | var set Set 18 | for k, v := range m { 19 | set = append(set, Tag{Name: k, Value: v}) 20 | } 21 | 22 | return set 23 | } 24 | 25 | // NewTagSetsFromMaps creates new tag sets from maps. 26 | func NewTagSetsFromMaps(maps []map[string]string) []Set { 27 | sets := make([]Set, 0, len(maps)) 28 | for _, m := range maps { 29 | sets = append(sets, NewTagSetFromMap(m)) 30 | } 31 | return sets 32 | } 33 | 34 | // Set is an ordered list of Tags. 35 | type Set []Tag 36 | 37 | // Contains indicates whether the name/value pair exists in the tagset. 38 | func (ts Set) Contains(name, value string) bool { 39 | for _, t := range ts { 40 | if t.Name == name && t.Value == value { 41 | return true 42 | } 43 | } 44 | 45 | return false 46 | } 47 | 48 | // ContainsAll indicates whether all the name/value pairs exist in the tagset. 49 | func (ts Set) ContainsAll(other []Tag) bool { 50 | for _, ot := range other { 51 | if !ts.Contains(ot.Name, ot.Value) { 52 | return false 53 | } 54 | } 55 | 56 | return true 57 | } 58 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package version // import "go.mongodb.org/mongo-driver/version" 8 | 9 | // Driver is the current version of the driver. 10 | var Driver = "v1.1.2" 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/bsonx/element.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonx 8 | 9 | import ( 10 | "fmt" 11 | 12 | "go.mongodb.org/mongo-driver/bson/bsontype" 13 | ) 14 | 15 | const validateMaxDepthDefault = 2048 16 | 17 | // ElementTypeError specifies that a method to obtain a BSON value an incorrect type was called on a bson.Value. 18 | // 19 | // TODO: rename this ValueTypeError. 20 | type ElementTypeError struct { 21 | Method string 22 | Type bsontype.Type 23 | } 24 | 25 | // Error implements the error interface. 26 | func (ete ElementTypeError) Error() string { 27 | return "Call of " + ete.Method + " on " + ete.Type.String() + " type" 28 | } 29 | 30 | // Elem represents a BSON element. 31 | // 32 | // NOTE: Element cannot be the value of a map nor a property of a struct without special handling. 33 | // The default encoders and decoders will not process Element correctly. To do so would require 34 | // information loss since an Element contains a key, but the keys used when encoding a struct are 35 | // the struct field names. Instead of using an Element, use a Value as a value in a map or a 36 | // property of a struct. 37 | type Elem struct { 38 | Key string 39 | Value Val 40 | } 41 | 42 | // Equal compares e and e2 and returns true if they are equal. 43 | func (e Elem) Equal(e2 Elem) bool { 44 | if e.Key != e2.Key { 45 | return false 46 | } 47 | return e.Value.Equal(e2.Value) 48 | } 49 | 50 | func (e Elem) String() string { 51 | // TODO(GODRIVER-612): When bsoncore has appenders for extended JSON use that here. 52 | return fmt.Sprintf(`bson.Element{"%s": %v}`, e.Key, e.Value) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/bsonx/registry.go: -------------------------------------------------------------------------------- 1 | package bsonx 2 | 3 | import ( 4 | "go.mongodb.org/mongo-driver/bson" 5 | "go.mongodb.org/mongo-driver/bson/bsoncodec" 6 | ) 7 | 8 | // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the 9 | // primitive codecs. 10 | var DefaultRegistry = NewRegistryBuilder().Build() 11 | 12 | // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and 13 | // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the 14 | // PrimitiveCodecs type in this package. 15 | func NewRegistryBuilder() *bsoncodec.RegistryBuilder { 16 | rb := bsoncodec.NewRegistryBuilder() 17 | bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb) 18 | bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb) 19 | bson.PrimitiveCodecs{}.RegisterPrimitiveCodecs(rb) 20 | primitiveCodecs.RegisterPrimitiveCodecs(rb) 21 | return rb 22 | } 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/DESIGN.md: -------------------------------------------------------------------------------- 1 | # Driver Library Design 2 | This document outlines the design for this package. 3 | 4 | ## Deployment, Server, and Connection 5 | Acquiring a `Connection` from a `Server` selected from a `Deployment` enables sending and receiving 6 | wire messages. A `Deployment` represents an set of MongoDB servers and a `Server` represents a 7 | member of that set. These three types form the operation execution stack. 8 | 9 | ### Compression 10 | Compression is handled by Connection type while uncompression is handled automatically by the 11 | Operation type. This is done because the compressor to use for compressing a wire message is 12 | chosen by the connection during handshake, while uncompression can be performed without this 13 | information. This does make the design of compression non-symmetric, but it makes the design simpler 14 | to implement and more consistent. 15 | 16 | ## Operation 17 | The `Operation` type handles executing a series of commands using a `Deployment`. For most uses 18 | `Operation` will only execute a single command, but the main use case for a series of commands is 19 | batch split write commands, such as insert. The type itself is heavily documented, so reading the 20 | code and comments together should provide an understanding of how the type works. 21 | 22 | This type is not meant to be used directly by callers. Instead an wrapping type should be defined 23 | using the IDL and an implementation generated using `operationgen`. 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/address/addr.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package address // import "go.mongodb.org/mongo-driver/x/mongo/driver/address" 8 | 9 | import ( 10 | "net" 11 | "strings" 12 | ) 13 | 14 | const defaultPort = "27017" 15 | 16 | // Address is a network address. It can either be an IP address or a DNS name. 17 | type Address string 18 | 19 | // Network is the network protocol for this address. In most cases this will be 20 | // "tcp" or "unix". 21 | func (a Address) Network() string { 22 | if strings.HasSuffix(string(a), "sock") { 23 | return "unix" 24 | } 25 | return "tcp" 26 | } 27 | 28 | // String is the canonical version of this address, e.g. localhost:27017, 29 | // 1.2.3.4:27017, example.com:27017. 30 | func (a Address) String() string { 31 | // TODO: unicode case folding? 32 | s := strings.ToLower(string(a)) 33 | if len(s) == 0 { 34 | return "" 35 | } 36 | if a.Network() != "unix" { 37 | _, _, err := net.SplitHostPort(s) 38 | if err != nil && strings.Contains(err.Error(), "missing port in address") { 39 | s += ":" + defaultPort 40 | } 41 | } 42 | 43 | return s 44 | } 45 | 46 | // Canonicalize creates a canonicalized address. 47 | func (a Address) Canonicalize() Address { 48 | return Address(a.String()) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/cred.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | // Cred is a user's credential. 10 | type Cred struct { 11 | Source string 12 | Username string 13 | Password string 14 | PasswordSet bool 15 | Props map[string]string 16 | } 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package auth is not for public use. 8 | // 9 | // The API for packages in the 'private' directory have no stability 10 | // guarantee. 11 | // 12 | // The packages within the 'private' directory would normally be put into an 13 | // 'internal' directory to prohibit their use outside the 'mongo' directory. 14 | // However, some MongoDB tools require very low-level access to the building 15 | // blocks of a driver, so we have placed them under 'private' to allow these 16 | // packages to be imported by projects that need them. 17 | // 18 | // These package APIs may be modified in backwards-incompatible ways at any 19 | // time. 20 | // 21 | // You are strongly discouraged from directly using any packages 22 | // under 'private'. 23 | package auth 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_enabled.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | //+build !gssapi 8 | 9 | package auth 10 | 11 | // GSSAPI is the mechanism name for GSSAPI. 12 | const GSSAPI = "GSSAPI" 13 | 14 | func newGSSAPIAuthenticator(cred *Cred) (Authenticator, error) { 15 | return nil, newAuthError("GSSAPI support not enabled during build (-tags gssapi)", nil) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_supported.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | //+build gssapi,!windows,!linux,!darwin 8 | 9 | package auth 10 | 11 | import ( 12 | "fmt" 13 | "runtime" 14 | ) 15 | 16 | // GSSAPI is the mechanism name for GSSAPI. 17 | const GSSAPI = "GSSAPI" 18 | 19 | func newGSSAPIAuthenticator(cred *Cred) (Authenticator, error) { 20 | return nil, newAuthError(fmt.Sprintf("GSSAPI is not supported on %s", runtime.GOOS), nil) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.h: -------------------------------------------------------------------------------- 1 | //+build gssapi 2 | //+build linux darwin 3 | #ifndef GSS_WRAPPER_H 4 | #define GSS_WRAPPER_H 5 | 6 | #include 7 | #ifdef GOOS_linux 8 | #include 9 | #include 10 | #endif 11 | #ifdef GOOS_darwin 12 | #include 13 | #endif 14 | 15 | #define GSSAPI_OK 0 16 | #define GSSAPI_CONTINUE 1 17 | #define GSSAPI_ERROR 2 18 | 19 | typedef struct { 20 | gss_name_t spn; 21 | gss_cred_id_t cred; 22 | gss_ctx_id_t ctx; 23 | 24 | OM_uint32 maj_stat; 25 | OM_uint32 min_stat; 26 | } gssapi_client_state; 27 | 28 | int gssapi_error_desc( 29 | OM_uint32 maj_stat, 30 | OM_uint32 min_stat, 31 | char **desc 32 | ); 33 | 34 | int gssapi_client_init( 35 | gssapi_client_state *client, 36 | char* spn, 37 | char* username, 38 | char* password 39 | ); 40 | 41 | int gssapi_client_username( 42 | gssapi_client_state *client, 43 | char** username 44 | ); 45 | 46 | int gssapi_client_negotiate( 47 | gssapi_client_state *client, 48 | void* input, 49 | size_t input_length, 50 | void** output, 51 | size_t* output_length 52 | ); 53 | 54 | int gssapi_client_wrap_msg( 55 | gssapi_client_state *client, 56 | void* input, 57 | size_t input_length, 58 | void** output, 59 | size_t* output_length 60 | ); 61 | 62 | int gssapi_client_destroy( 63 | gssapi_client_state *client 64 | ); 65 | 66 | #endif -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/sspi_wrapper.h: -------------------------------------------------------------------------------- 1 | //+build gssapi,windows 2 | 3 | #ifndef SSPI_WRAPPER_H 4 | #define SSPI_WRAPPER_H 5 | 6 | #define SECURITY_WIN32 1 /* Required for SSPI */ 7 | 8 | #include 9 | #include 10 | 11 | #define SSPI_OK 0 12 | #define SSPI_CONTINUE 1 13 | #define SSPI_ERROR 2 14 | 15 | typedef struct { 16 | CredHandle cred; 17 | CtxtHandle ctx; 18 | 19 | int has_ctx; 20 | 21 | SECURITY_STATUS status; 22 | } sspi_client_state; 23 | 24 | int sspi_init(); 25 | 26 | int sspi_client_init( 27 | sspi_client_state *client, 28 | char* username, 29 | char* password 30 | ); 31 | 32 | int sspi_client_username( 33 | sspi_client_state *client, 34 | char** username 35 | ); 36 | 37 | int sspi_client_negotiate( 38 | sspi_client_state *client, 39 | char* spn, 40 | PVOID input, 41 | ULONG input_length, 42 | PVOID* output, 43 | ULONG* output_length 44 | ); 45 | 46 | int sspi_client_wrap_msg( 47 | sspi_client_state *client, 48 | PVOID input, 49 | ULONG input_length, 50 | PVOID* output, 51 | ULONG* output_length 52 | ); 53 | 54 | int sspi_client_destroy( 55 | sspi_client_state *client 56 | ); 57 | 58 | #endif -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/plain.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "context" 11 | 12 | "go.mongodb.org/mongo-driver/x/mongo/driver" 13 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 14 | ) 15 | 16 | // PLAIN is the mechanism name for PLAIN. 17 | const PLAIN = "PLAIN" 18 | 19 | func newPlainAuthenticator(cred *Cred) (Authenticator, error) { 20 | return &PlainAuthenticator{ 21 | Username: cred.Username, 22 | Password: cred.Password, 23 | }, nil 24 | } 25 | 26 | // PlainAuthenticator uses the PLAIN algorithm over SASL to authenticate a connection. 27 | type PlainAuthenticator struct { 28 | Username string 29 | Password string 30 | } 31 | 32 | // Auth authenticates the connection. 33 | func (a *PlainAuthenticator) Auth(ctx context.Context, _ description.Server, conn driver.Connection) error { 34 | return ConductSaslConversation(ctx, conn, "$external", &plainSaslClient{ 35 | username: a.Username, 36 | password: a.Password, 37 | }) 38 | } 39 | 40 | type plainSaslClient struct { 41 | username string 42 | password string 43 | } 44 | 45 | func (c *plainSaslClient) Start() (string, []byte, error) { 46 | b := []byte("\x00" + c.username + "\x00" + c.password) 47 | return PLAIN, b, nil 48 | } 49 | 50 | func (c *plainSaslClient) Next(challenge []byte) ([]byte, error) { 51 | return nil, newAuthError("unexpected server challenge", nil) 52 | } 53 | 54 | func (c *plainSaslClient) Completed() bool { 55 | return true 56 | } 57 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "crypto/md5" 11 | "fmt" 12 | "io" 13 | ) 14 | 15 | const defaultAuthDB = "admin" 16 | 17 | func mongoPasswordDigest(username, password string) string { 18 | h := md5.New() 19 | _, _ = io.WriteString(h, username) 20 | _, _ = io.WriteString(h, ":mongo:") 21 | _, _ = io.WriteString(h, password) 22 | return fmt.Sprintf("%x", h.Sum(nil)) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/x509.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "context" 11 | 12 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 13 | "go.mongodb.org/mongo-driver/x/mongo/driver" 14 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 15 | "go.mongodb.org/mongo-driver/x/mongo/driver/operation" 16 | ) 17 | 18 | // MongoDBX509 is the mechanism name for MongoDBX509. 19 | const MongoDBX509 = "MONGODB-X509" 20 | 21 | func newMongoDBX509Authenticator(cred *Cred) (Authenticator, error) { 22 | return &MongoDBX509Authenticator{User: cred.Username}, nil 23 | } 24 | 25 | // MongoDBX509Authenticator uses X.509 certificates over TLS to authenticate a connection. 26 | type MongoDBX509Authenticator struct { 27 | User string 28 | } 29 | 30 | // Auth implements the Authenticator interface. 31 | func (a *MongoDBX509Authenticator) Auth(ctx context.Context, desc description.Server, conn driver.Connection) error { 32 | requestDoc := bsoncore.AppendInt32Element(nil, "authenticate", 1) 33 | requestDoc = bsoncore.AppendStringElement(requestDoc, "mechanism", MongoDBX509) 34 | 35 | if desc.WireVersion == nil || desc.WireVersion.Max < 5 { 36 | requestDoc = bsoncore.AppendStringElement(requestDoc, "user", a.User) 37 | } 38 | 39 | authCmd := operation. 40 | NewCommand(bsoncore.BuildDocument(nil, requestDoc)). 41 | Database("$external"). 42 | Deployment(driver.SingleConnectionDeployment{conn}) 43 | err := authCmd.Execute(ctx) 44 | if err != nil { 45 | return newAuthError("round trip error", err) 46 | } 47 | 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/description.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description // import "go.mongodb.org/mongo-driver/x/mongo/driver/description" 8 | 9 | // Unknown is an unknown server or topology kind. 10 | const Unknown = 0 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/feature.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import ( 10 | "fmt" 11 | ) 12 | 13 | // MaxStalenessSupported returns an error if the given server version 14 | // does not support max staleness. 15 | func MaxStalenessSupported(wireVersion *VersionRange) error { 16 | if wireVersion != nil && wireVersion.Max < 5 { 17 | return fmt.Errorf("max staleness is only supported for servers 3.4 or newer") 18 | } 19 | 20 | return nil 21 | } 22 | 23 | // ScramSHA1Supported returns an error if the given server version 24 | // does not support scram-sha-1. 25 | func ScramSHA1Supported(wireVersion *VersionRange) error { 26 | if wireVersion != nil && wireVersion.Max < 3 { 27 | return fmt.Errorf("SCRAM-SHA-1 is only supported for servers 3.0 or newer") 28 | } 29 | 30 | return nil 31 | } 32 | 33 | // SessionsSupported returns true of the given server version indicates that it supports sessions. 34 | func SessionsSupported(wireVersion *VersionRange) bool { 35 | return wireVersion != nil && wireVersion.Max >= 6 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/server_kind.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | // ServerKind represents the type of a server. 10 | type ServerKind uint32 11 | 12 | // These constants are the possible types of servers. 13 | const ( 14 | Standalone ServerKind = 1 15 | RSMember ServerKind = 2 16 | RSPrimary ServerKind = 4 + RSMember 17 | RSSecondary ServerKind = 8 + RSMember 18 | RSArbiter ServerKind = 16 + RSMember 19 | RSGhost ServerKind = 32 + RSMember 20 | Mongos ServerKind = 256 21 | ) 22 | 23 | // String implements the fmt.Stringer interface. 24 | func (kind ServerKind) String() string { 25 | switch kind { 26 | case Standalone: 27 | return "Standalone" 28 | case RSMember: 29 | return "RSOther" 30 | case RSPrimary: 31 | return "RSPrimary" 32 | case RSSecondary: 33 | return "RSSecondary" 34 | case RSArbiter: 35 | return "RSArbiter" 36 | case RSGhost: 37 | return "RSGhost" 38 | case Mongos: 39 | return "Mongos" 40 | } 41 | 42 | return "Unknown" 43 | } 44 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/topology_kind.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | // TopologyKind represents a specific topology configuration. 10 | type TopologyKind uint32 11 | 12 | // These constants are the available topology configurations. 13 | const ( 14 | Single TopologyKind = 1 15 | ReplicaSet TopologyKind = 2 16 | ReplicaSetNoPrimary TopologyKind = 4 + ReplicaSet 17 | ReplicaSetWithPrimary TopologyKind = 8 + ReplicaSet 18 | Sharded TopologyKind = 256 19 | ) 20 | 21 | // String implements the fmt.Stringer interface. 22 | func (kind TopologyKind) String() string { 23 | switch kind { 24 | case Single: 25 | return "Single" 26 | case ReplicaSet: 27 | return "ReplicaSet" 28 | case ReplicaSetNoPrimary: 29 | return "ReplicaSetNoPrimary" 30 | case ReplicaSetWithPrimary: 31 | return "ReplicaSetWithPrimary" 32 | case Sharded: 33 | return "Sharded" 34 | } 35 | 36 | return "Unknown" 37 | } 38 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import "strconv" 10 | 11 | // Version represents a software version. 12 | type Version struct { 13 | Desc string 14 | Parts []uint8 15 | } 16 | 17 | // AtLeast ensures that the version is at least as large as the "other" version. 18 | func (v Version) AtLeast(other ...uint8) bool { 19 | for i := range other { 20 | if i == len(v.Parts) { 21 | return false 22 | } 23 | if v.Parts[i] < other[i] { 24 | return false 25 | } 26 | } 27 | return true 28 | } 29 | 30 | // String provides the string represtation of the Version. 31 | func (v Version) String() string { 32 | if v.Desc == "" { 33 | var s string 34 | for i, p := range v.Parts { 35 | if i != 0 { 36 | s += "." 37 | } 38 | s += strconv.Itoa(int(p)) 39 | } 40 | return s 41 | } 42 | 43 | return v.Desc 44 | } 45 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/version_range.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import "fmt" 10 | 11 | // VersionRange represents a range of versions. 12 | type VersionRange struct { 13 | Min int32 14 | Max int32 15 | } 16 | 17 | // NewVersionRange creates a new VersionRange given a min and a max. 18 | func NewVersionRange(min, max int32) VersionRange { 19 | return VersionRange{Min: min, Max: max} 20 | } 21 | 22 | // Includes returns a bool indicating whether the supplied integer is included 23 | // in the range. 24 | func (vr VersionRange) Includes(v int32) bool { 25 | return v >= vr.Min && v <= vr.Max 26 | } 27 | 28 | // String implements the fmt.Stringer interface. 29 | func (vr VersionRange) String() string { 30 | return fmt.Sprintf("[%d, %d]", vr.Min, vr.Max) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/legacy.go: -------------------------------------------------------------------------------- 1 | package driver 2 | 3 | // LegacyOperationKind indicates if an operation is a legacy find, getMore, or killCursors. This is used 4 | // in Operation.Execute, which will create legacy OP_QUERY, OP_GET_MORE, or OP_KILL_CURSORS instead 5 | // of sending them as a command. 6 | type LegacyOperationKind uint 7 | 8 | // These constants represent the three different kinds of legacy operations. 9 | const ( 10 | LegacyNone LegacyOperationKind = iota 11 | LegacyFind 12 | LegacyGetMore 13 | LegacyKillCursors 14 | LegacyListCollections 15 | LegacyListIndexes 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/abort_transaction.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "AbortTransaction" 3 | documentation = "AbortTransaction performs an abortTransaction operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | 9 | [command] 10 | name = "abortTransaction" 11 | parameter = "database" 12 | 13 | [request.recoveryToken] 14 | type = "document" 15 | documentation = """ 16 | RecoveryToken sets the recovery token to use when committing or aborting a sharded transaction.\ 17 | """ 18 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/aggregate.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Aggregate" 3 | documentation = "Performs an aggregate operation" 4 | response.type = "batch cursor" 5 | 6 | [properties] 7 | enabled = ["read concern", "read preference", "write concern"] 8 | retryable = {mode = "once per command", type = "reads"} 9 | MinimumWriteConcernWireVersion = 5 10 | 11 | [command] 12 | name = "aggregate" 13 | parameter = "collection" 14 | database = true 15 | 16 | [request.pipeline] 17 | type = "array" 18 | constructor = true 19 | documentation = "Pipeline determines how data is transformed for an aggregation." 20 | 21 | [request.allowDiskUse] 22 | type = "boolean" 23 | documentation = "AllowDiskUse enables writing to temporary files. When true, aggregation stages can write to the dbPath/_tmp directory." 24 | 25 | [request.batchSize] 26 | type = "int32" 27 | documentation = "BatchSize specifies the number of documents to return in every batch." 28 | 29 | [request.bypassDocumentValidation] 30 | type = "boolean" 31 | documentation = "BypassDocumentValidation allows the write to opt-out of document level validation. This only applies when the $out stage is specified." 32 | 33 | [request.collation] 34 | type = "document" 35 | minWireVersionRequired = 5 36 | documentation = "Collation specifies a collation. This option is only valid for server versions 3.4 and above." 37 | 38 | [request.maxTimeMS] 39 | type = "int64" 40 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 41 | 42 | [request.comment] 43 | type = "string" 44 | documentation = "Comment specifies an arbitrary string to help trace the operation through the database profiler, currentOp, and logs." 45 | 46 | [request.hint] 47 | type = "value" 48 | documentation = "Hint specifies the index to use." 49 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/commit_transaction.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "CommitTransaction" 3 | documentation = "CommitTransaction attempts to commit a transaction." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | disabled = ["collection"] 8 | retryable = {mode = "once per command", type = "writes"} 9 | 10 | [command] 11 | name = "commitTransaction" 12 | parameter = "database" 13 | 14 | [request.recoveryToken] 15 | type = "document" 16 | documentation = """ 17 | RecoveryToken sets the recovery token to use when committing or aborting a sharded transaction.\ 18 | """ 19 | 20 | [request.maxTimeMS] 21 | type = "int64" 22 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/count.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Count" 3 | documentation = "Performs a count operation" 4 | 5 | [properties] 6 | enabled = ["read concern", "read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | 9 | [command] 10 | name = "count" 11 | parameter = "collection" 12 | 13 | [request.maxTimeMS] 14 | type = "int64" 15 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 16 | 17 | [request.query] 18 | type = "document" 19 | documentation = "Query determines what results are returned from find." 20 | 21 | [response] 22 | name = "CountResult" 23 | 24 | [response.field.n] 25 | type = "int64" 26 | documentation = "The number of documents found" 27 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/createIndexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "CreateIndexes" 3 | documentation = "CreateIndexes performs a createIndexes operation." 4 | 5 | [command] 6 | name = "createIndexes" 7 | parameter = "collection" 8 | 9 | [request.indexes] 10 | type = "array" 11 | constructor = true 12 | documentation = "An array containing index specification documents for the indexes being created." 13 | 14 | [request.maxTimeMS] 15 | type = "int64" 16 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 17 | 18 | [response] 19 | name = "CreateIndexesResult" 20 | 21 | [response.field.createdCollectionAutomatically] 22 | type = "boolean" 23 | documentation = "If the collection was created automatically." 24 | 25 | [response.field.indexesBefore] 26 | type = "int32" 27 | documentation = "The number of indexes existing before this command." 28 | 29 | [response.field.indexesAfter] 30 | type = "int32" 31 | documentation = "The number of indexes existing after this command." 32 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/delete.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Delete" 3 | documentation = "Delete performs a delete operation" 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "deletes" 9 | 10 | [command] 11 | name = "delete" 12 | parameter = "collection" 13 | 14 | [request.deletes] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Deletes adds documents to this operation that will be used to determine what documents to delete when this operation 22 | is executed. These documents should have the form {q: , limit: , collation: }. The 23 | collation field is optional. If limit is 0, there will be no limit on the number of documents deleted.\ 24 | """ 25 | 26 | [request.ordered] 27 | type = "boolean" 28 | documentation = """ 29 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 30 | false write failures do not stop execution of the operation.\ 31 | """ 32 | 33 | [response] 34 | name = "DeleteResult" 35 | 36 | [response.field.n] 37 | type = "int32" 38 | documentation = "Number of documents successfully deleted." 39 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/distinct.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Distinct" 3 | documentation = "Distinct performs a distinct operation." 4 | 5 | [properties] 6 | enabled = ["read concern", "read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | 9 | [command] 10 | name = "distinct" 11 | parameter = "collection" 12 | 13 | [request.key] 14 | type = "string" 15 | constructor = true 16 | documentation = "Key specifies which field to return distinct values for." 17 | 18 | [request.query] 19 | type = "document" 20 | constructor = true 21 | documentation = "Query specifies which documents to return distinct values from." 22 | 23 | [request.maxTimeMS] 24 | type = "int64" 25 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 26 | 27 | [request.collation] 28 | type = "document" 29 | minWireVersionRequired = 5 30 | documentation = "Collation specifies a collation to be used." 31 | 32 | [response] 33 | name = "DistinctResult" 34 | 35 | [response.field.values] 36 | type = "value" 37 | documentation = "The distinct values for the field." -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_collection.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropCollection" 3 | documentation = "DropCollection performs a drop operation." 4 | 5 | [command] 6 | name = "drop" 7 | parameter = "collection" 8 | 9 | [properties] 10 | enabled = ["write concern"] 11 | 12 | [response] 13 | name = "DropCollectionResult" 14 | 15 | [response.field.ns] 16 | type = "string" 17 | documentation = "The namespace of the dropped collection." 18 | 19 | [response.field.nIndexesWas] 20 | type = "int32" 21 | documentation = "The number of indexes in the dropped collection." 22 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_database.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropDatabase" 3 | documentation = "DropDatabase performs a dropDatabase operation" 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | disabled = ["collection"] 8 | 9 | [command] 10 | name = "dropDatabase" 11 | parameter = "database" 12 | 13 | [response] 14 | name = "DropDatabaseResult" 15 | 16 | [response.field.dropped] 17 | type = "string" 18 | documentation = "The dropped database." -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_indexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropIndexes" 3 | documentation = "DropIndexes performs an dropIndexes operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | 8 | [command] 9 | name = "dropIndexes" 10 | parameter = "collection" 11 | 12 | [request.index] 13 | type = "string" 14 | constructor = true 15 | documentation = """ 16 | Index specifies the name of the index to drop. If '*' is specified, all indexes will be dropped. 17 | """ 18 | 19 | [request.maxTimeMS] 20 | type = "int64" 21 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 22 | 23 | [response] 24 | name = "DropIndexesResult" 25 | 26 | [response.field.nIndexesWas] 27 | type = "int32" 28 | documentation = "Number of indexes that existed before the drop was executed." 29 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/end_sessions.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "EndSessions" 3 | documentation = "EndSessions performs an endSessions operation." 4 | 5 | [properties] 6 | disabled = ["collection"] 7 | 8 | [command] 9 | name = "endSessions" 10 | parameter = "sessionIDs" 11 | 12 | [request.sessionIDs] 13 | type = "array" 14 | documentation = "sessionIDs specify the sessions to be expired." 15 | skip = true 16 | constructor = true 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Insert" 3 | documentation = "Insert performs an insert operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "documents" 9 | 10 | [command] 11 | name = "insert" 12 | parameter = "collection" 13 | 14 | [request.documents] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Documents adds documents to this operation that will be inserted when this operation is 22 | executed.\ 23 | """ 24 | 25 | [request.ordered] 26 | type = "boolean" 27 | documentation = """ 28 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 29 | false write failures do not stop execution of the operation.\ 30 | """ 31 | 32 | [request.bypassDocumentValidation] 33 | type = "boolean" 34 | minWireVersion = 4 35 | documentation = """ 36 | BypassDocumentValidation allows the operation to opt-out of document level validation. Valid 37 | for server versions >= 3.2. For servers < 3.2, this setting is ignored.\ 38 | """ 39 | 40 | [response] 41 | name = "InsertResult" 42 | 43 | [response.field.n] 44 | type = "int32" 45 | documentation = "Number of documents successfully inserted." 46 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/listDatabases.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListDatabases" 3 | documentation = "ListDatabases performs a listDatabases operation." 4 | 5 | [properties] 6 | enabled = ["read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | disabled = ["collection"] 9 | 10 | [command] 11 | name = "listDatabases" 12 | parameter = "database" 13 | 14 | [request.filter] 15 | type = "document" 16 | constructor = true 17 | documentation = "Filter determines what results are returned from listDatabases." 18 | 19 | 20 | [request.nameOnly] 21 | type = "boolean" 22 | documentation = "NameOnly specifies whether to only return database names." 23 | 24 | [response] 25 | name = "ListDatabasesResult" 26 | 27 | [response.field.totalSize] 28 | type = "int64" 29 | documentation = "The sum of the size of all the database files on disk in bytes." 30 | 31 | [response.field.databases] 32 | type = "value" 33 | documentation = "An array of documents, one document for each database" -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_collections.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListCollections" 3 | documentation = "ListCollections performs a listCollections operation." 4 | response.type = "list collections batch cursor" 5 | 6 | [properties] 7 | enabled = ["read preference"] 8 | disabled = ["collection"] 9 | retryable = {mode = "once per command", type = "reads"} 10 | legacy = "listCollections" 11 | 12 | [command] 13 | name = "listCollections" 14 | parameter = "database" 15 | 16 | [request.filter] 17 | type = "document" 18 | constructor = true 19 | documentation = "Filter determines what results are returned from listCollections." 20 | 21 | [request.nameOnly] 22 | type = "boolean" 23 | documentation = "NameOnly specifies whether to only return collection names." 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_indexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListIndexes" 3 | documentation = "ListIndexes performs a listIndexes operation." 4 | response.type = "batch cursor" 5 | 6 | [properties] 7 | legacy = "listIndexes" 8 | retryable = {mode = "once per command", type = "reads"} 9 | 10 | [command] 11 | name = "listIndexes" 12 | parameter = "collection" 13 | 14 | [request.batchSize] 15 | type = "int32" 16 | documentation = "BatchSize specifies the number of documents to return in every batch." 17 | 18 | [request.maxTimeMS] 19 | type = "int64" 20 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 21 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/operation.go: -------------------------------------------------------------------------------- 1 | package operation 2 | 3 | //go:generate operationgen insert.toml operation insert.go 4 | //go:generate operationgen find.toml operation find.go 5 | //go:generate operationgen list_collections.toml operation list_collections.go 6 | //go:generate operationgen createIndexes.toml operation createIndexes.go 7 | //go:generate operationgen drop_collection.toml operation drop_collection.go 8 | //go:generate operationgen distinct.toml operation distinct.go 9 | //go:generate operationgen delete.toml operation delete.go 10 | //go:generate operationgen drop_indexes.toml operation drop_indexes.go 11 | //go:generate operationgen drop_database.toml operation drop_database.go 12 | //go:generate operationgen commit_transaction.toml operation commit_transaction.go 13 | //go:generate operationgen abort_transaction.toml operation abort_transaction.go 14 | //go:generate operationgen count.toml operation count.go 15 | //go:generate operationgen end_sessions.toml operation end_sessions.go 16 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Update" 3 | documentation = "Update performs an update operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "updates" 9 | 10 | [command] 11 | name = "update" 12 | parameter = "collection" 13 | 14 | [request.updates] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Updates specifies an array of update statements to perform when this operation is executed. 22 | Each update document must have the following structure: {q: , u: , multi: , collation: Optional, arrayFitlers: Optional}.\ 23 | """ 24 | 25 | [request.ordered] 26 | type = "boolean" 27 | documentation = """ 28 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 29 | false write failures do not stop execution of the operation.\ 30 | """ 31 | 32 | [request.bypassDocumentValidation] 33 | type = "boolean" 34 | minWireVersion = 4 35 | documentation = """ 36 | BypassDocumentValidation allows the operation to opt-out of document level validation. Valid 37 | for server versions >= 3.2. For servers < 3.2, this setting is ignored.\ 38 | """ 39 | 40 | [response] 41 | name = "UpdateResult" 42 | 43 | [response.field.n] 44 | type = "int32" 45 | documentation = "Number of documents matched." 46 | 47 | [response.field.nModified] 48 | type = "int32" 49 | documentation = "Number of documents modified." 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/cluster_clock.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package session 8 | 9 | import ( 10 | "sync" 11 | 12 | "go.mongodb.org/mongo-driver/bson" 13 | ) 14 | 15 | // ClusterClock represents a logical clock for keeping track of cluster time. 16 | type ClusterClock struct { 17 | clusterTime bson.Raw 18 | lock sync.Mutex 19 | } 20 | 21 | // GetClusterTime returns the cluster's current time. 22 | func (cc *ClusterClock) GetClusterTime() bson.Raw { 23 | var ct bson.Raw 24 | cc.lock.Lock() 25 | ct = cc.clusterTime 26 | cc.lock.Unlock() 27 | 28 | return ct 29 | } 30 | 31 | // AdvanceClusterTime updates the cluster's current time. 32 | func (cc *ClusterClock) AdvanceClusterTime(clusterTime bson.Raw) { 33 | cc.lock.Lock() 34 | cc.clusterTime = MaxClusterTime(cc.clusterTime, clusterTime) 35 | cc.lock.Unlock() 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_legacy.go: -------------------------------------------------------------------------------- 1 | package topology 2 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_legacy_command_metadata.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import "time" 4 | 5 | // commandMetadata contains metadata about a command sent to the server. 6 | type commandMetadata struct { 7 | Name string 8 | Time time.Time 9 | Legacy bool 10 | FullCollectionName string 11 | } 12 | 13 | // createMetadata creates metadata for a command. 14 | func createMetadata(name string, legacy bool, fullCollName string) *commandMetadata { 15 | return &commandMetadata{ 16 | Name: name, 17 | Time: time.Now(), 18 | Legacy: legacy, 19 | FullCollectionName: fullCollName, 20 | } 21 | } 22 | 23 | // TimeDifference returns the difference between now and the time a command was sent in nanoseconds. 24 | func (cm *commandMetadata) TimeDifference() int64 { 25 | t := time.Now() 26 | duration := t.Sub(cm.Time) 27 | return duration.Nanoseconds() 28 | } 29 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import "fmt" 4 | 5 | // ConnectionError represents a connection error. 6 | type ConnectionError struct { 7 | ConnectionID string 8 | Wrapped error 9 | 10 | // init will be set to true if this error occured during connection initialization or 11 | // during a connection handshake. 12 | init bool 13 | message string 14 | } 15 | 16 | // Error implements the error interface. 17 | func (e ConnectionError) Error() string { 18 | if e.Wrapped != nil { 19 | return fmt.Sprintf("connection(%s) %s: %s", e.ConnectionID, e.message, e.Wrapped.Error()) 20 | } 21 | return fmt.Sprintf("connection(%s) %s", e.ConnectionID, e.message) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology_options_1_10.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package topology 4 | 5 | import "crypto/x509" 6 | 7 | func x509CertSubject(cert *x509.Certificate) string { 8 | return cert.Subject.String() 9 | } 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology_options_1_9.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package topology 4 | 5 | import ( 6 | "crypto/x509" 7 | ) 8 | 9 | // We don't support version less then 1.10, but Evergreen needs to be able to compile the driver 10 | // using version 1.8. 11 | func x509CertSubject(cert *x509.Certificate) string { 12 | return "" 13 | } 14 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/uuid/uuid.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package uuid // import "go.mongodb.org/mongo-driver/x/mongo/driver/uuid" 8 | 9 | import ( 10 | "bytes" 11 | "crypto/rand" 12 | "io" 13 | ) 14 | 15 | // UUID represents a UUID. 16 | type UUID [16]byte 17 | 18 | var rander = rand.Reader 19 | 20 | // New generates a new uuid. 21 | func New() (UUID, error) { 22 | var uuid [16]byte 23 | 24 | _, err := io.ReadFull(rander, uuid[:]) 25 | if err != nil { 26 | return [16]byte{}, err 27 | } 28 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 29 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 30 | 31 | return uuid, nil 32 | } 33 | 34 | // Equal returns true if two UUIDs are equal. 35 | func Equal(a, b UUID) bool { 36 | return bytes.Equal([]byte(a[:]), []byte(b[:])) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | --------------------------------------------------------------------------------