diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c7b0399..0916660 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,33 +14,33 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go_version: [1.11, 1.12, 1.13] + go_version: [1.16] os: [ubuntu-latest, macOS-latest] steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - name: Set up Go ${{ matrix.go_version }} + uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: ${{ matrix.go_version }} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v2 - - name: Test + - name: Run Unit Tests run: ./scripts/runUnitTests.sh lint: name: Lint runs-on: ubuntu-latest steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - name: Set up latest stable Go + uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: "^1.16" id: go - name: Check out code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Lint run: | diff --git a/LICENSE b/LICENSE index 3c3e635..023ca5d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,224 @@ -MIT License +TRYVIUM SOFTWARE LICENSE -Copyright (c) 2019 Ben Weissmann +This project is Licensed under Apache license, version 2, but was forked from a +project with MIT License (https://github.com/benweissmann/memongo). +The latest version prior the fork was 0.1.1, so until that version the +old license applies. + +Any subsequent work is licensed under the Apache license, version 2. +Please see the licenses texts below for the details of the respective licenses. + +APACHE LICENSE, VERSION 2, JANUARY 2004, FOR MEMONGO FROM VERSION 0.1.2 +-------------------------------------------------- + +Copyright (c) 2021 Tryvium Travels LTD + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +MIT LICENSE FOR MEMONGO UNTIL VERSION 0.1.1 +-------------------------------------------------- + +Copyright (c) 2019-2020 Ben Weissmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f0f0ec9..d4b262b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # memongo -[![CI](https://github.com/benweissmann/memongo/workflows/Go/badge.svg)](https://github.com/benweissmann/memongo/actions?workflow=Go) [![GoDoc](https://godoc.org/github.com/benweissmann/memongo?status.svg)](https://godoc.org/github.com/benweissmann/memongo) [![Go Report Card](https://goreportcard.com/badge/github.com/benweissmann/memongo)](https://goreportcard.com/report/github.com/benweissmann/memongo) +[![CI](https://github.com/tryvium-travels/memongo/workflows/Go/badge.svg)](https://github.com/tryvium-travels/memongo/actions?workflow=Go) [![GoDoc](https://godoc.org/github.com/tryvium-travels/memongo?status.svg)](https://godoc.org/github.com/tryvium-travels/memongo) [![Go Report Card](https://goreportcard.com/badge/github.com/tryvium-travels/memongo)](https://goreportcard.com/report/github.com/tryvium-travels/memongo) `memongo` is a Go package that spins up a real MongoDB server, backed by in-memory storage, for use in testing and mocking during development. It's based on @@ -83,7 +83,7 @@ Behind the scenes, when you run `Start()`, a few things are happening: The behavior of `memongo` can be controlled by using `memongo.StartWithOptions` instead of `memongo.Start`. See -[the godoc](https://godoc.org/github.com/benweissmann/memongo) for all the options. Many options can also be set via environment variable. +[the godoc](https://godoc.org/github.com/tryvium-travels/memongo) for all the options. Many options can also be set via environment variable. A few common use-cases are covered here: diff --git a/config.go b/config.go index 7f4891c..900dae1 100644 --- a/config.go +++ b/config.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package memongo import ( @@ -12,8 +27,8 @@ import ( "strings" "time" - "github.com/benweissmann/memongo/memongolog" - "github.com/benweissmann/memongo/mongobin" + "github.com/tryvium-travels/memongo/memongolog" + "github.com/tryvium-travels/memongo/mongobin" ) // Options is the configuration options for a launched MongoDB binary diff --git a/go.mod b/go.mod index 4554f02..59cd986 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,10 @@ -module github.com/benweissmann/memongo +module github.com/tryvium-travels/memongo + +go 1.16 require ( github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 - github.com/go-stack/stack v1.8.0 // indirect - github.com/golang/snappy v0.0.1 // indirect - github.com/google/go-cmp v0.3.0 // indirect - github.com/nats-io/gnatsd v1.4.1 - github.com/spf13/afero v1.2.1 - github.com/stretchr/testify v1.3.0 - github.com/tidwall/pretty v1.0.0 // indirect - github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect - github.com/xdg/stringprep v1.0.0 // indirect - go.mongodb.org/mongo-driver v1.0.3 - golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443 // indirect - golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect + github.com/spf13/afero v1.6.0 + github.com/stretchr/testify v1.7.0 + go.mongodb.org/mongo-driver v1.7.0 ) diff --git a/go.sum b/go.sum index 5ced128..cef97bc 100644 --- a/go.sum +++ b/go.sum @@ -1,38 +1,130 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 h1:fMi9ZZ/it4orHj3xWrM6cLkVFcCbkXQALFUiNtHtCPs= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249/go.mod h1:iU1PxQMQwoHZZWmMKrMkrNlY+3+p9vxIjpZOVyxWa0g= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/nats-io/gnatsd v1.4.1 h1:RconcfDeWpKCD6QIIwiVFcvForlXpWeJP7i5/lDLy44= -github.com/nats-io/gnatsd v1.4.1/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/klauspost/compress v1.9.5 h1:U+CaK85mrNNb4k8BNOfgJtJ/gr6kswUCFj6miSzVC6M= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spf13/afero v1.2.1 h1:qgMbHoJbPbw579P+1zVY+6n4nIFuIchaIjzZ/I/Yq8M= -github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0= -github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= -go.mongodb.org/mongo-driver v1.0.3 h1:GKoji1ld3tw2aC+GX1wbr/J2fX13yNacEYoJ8Nhr0yU= -go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.1.2 h1:jxcFYjlkl8xaERsgLo+RNquI0epW6zuy/ZRQs6jnrFA= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +go.mongodb.org/mongo-driver v1.7.0 h1:hHrvOBWlWB2c7+8Gh/Xi5jj82AgidK/t7KVXBZ+IyUA= +go.mongodb.org/mongo-driver v1.7.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443 h1:IcSOAf4PyMp3U3XbIEj1/xJ2BjNN2jWv7JoyOsMxXUU= -golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main_test.go b/main_test.go deleted file mode 100644 index 47430c3..0000000 --- a/main_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package memongo - -import ( - "context" - "testing" - - "github.com/benweissmann/memongo/memongolog" - - "github.com/stretchr/testify/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" -) - -func TestDefaultOptions(t *testing.T) { - versions := []string{"3.2.22", "3.4.21", "3.6.13", "4.0.13", "4.2.1"} - - for _, version := range versions { - t.Run(version, func(t *testing.T) { - server, err := StartWithOptions(&Options{ - MongoVersion: version, - LogLevel: memongolog.LogLevelDebug, - }) - require.NoError(t, err) - defer server.Stop() - - client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(server.URI())) - require.NoError(t, err) - - require.NoError(t, client.Ping(context.Background(), nil)) - }) - } -} diff --git a/main.go b/memongo.go similarity index 90% rename from main.go rename to memongo.go index 9a49af4..62daad1 100644 --- a/main.go +++ b/memongo.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package memongo import ( @@ -13,8 +28,8 @@ import ( "strings" "time" - "github.com/benweissmann/memongo/memongolog" - "github.com/benweissmann/memongo/monitor" + "github.com/tryvium-travels/memongo/memongolog" + "github.com/tryvium-travels/memongo/monitor" ) // Server represents a running MongoDB server @@ -185,7 +200,7 @@ func (s *Server) Stop() { } // Cribbed from https://github.com/nodkz/mongodb-memory-server/blob/master/packages/mongodb-memory-server-core/src/util/MongoInstance.ts#L206 -var reReady = regexp.MustCompile(`waiting for connections on port (\d+)`) +var reReady = regexp.MustCompile(`waiting for connections.*port\D*(\d+)`) var reAlreadyInUse = regexp.MustCompile("addr already in use") var reAlreadyRunning = regexp.MustCompile("mongod already running") var rePermissionDenied = regexp.MustCompile("mongod permission denied") diff --git a/memongo_test.go b/memongo_test.go new file mode 100644 index 0000000..8613352 --- /dev/null +++ b/memongo_test.go @@ -0,0 +1,48 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package memongo_test + +import ( + "context" + "testing" + + "github.com/tryvium-travels/memongo" + "github.com/tryvium-travels/memongo/memongolog" + + "github.com/stretchr/testify/require" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +func TestDefaultOptions(t *testing.T) { + versions := []string{"4.4.7", "5.0.0"} + + for _, version := range versions { + t.Run(version, func(t *testing.T) { + server, err := memongo.StartWithOptions(&memongo.Options{ + MongoVersion: version, + LogLevel: memongolog.LogLevelDebug, + }) + require.NoError(t, err) + defer server.Stop() + + client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(server.URI())) + require.NoError(t, err) + + require.NoError(t, client.Ping(context.Background(), nil)) + }) + } +} diff --git a/memongolog/logger.go b/memongolog/logger.go index a30f8a9..671faa0 100644 --- a/memongolog/logger.go +++ b/memongolog/logger.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package memongolog import ( diff --git a/memongolog/logger_test.go b/memongolog/logger_test.go index 8729119..5f645d5 100644 --- a/memongolog/logger_test.go +++ b/memongolog/logger_test.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package memongolog import ( diff --git a/mongobin/downloadSpec.go b/mongobin/downloadSpec.go index 4e98acb..4b1b728 100644 --- a/mongobin/downloadSpec.go +++ b/mongobin/downloadSpec.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mongobin import ( @@ -10,10 +25,10 @@ import ( ) // We define these as package vars so we can override it in tests -var etcOsRelease = "/etc/os-release" -var etcRedhatRelease = "/etc/redhat-release" -var goOS = runtime.GOOS -var goArch = runtime.GOARCH +var EtcOsRelease = "/etc/os-release" +var EtcRedhatRelease = "/etc/redhat-release" +var GoOS = runtime.GOOS +var GoArch = runtime.GOARCH // DownloadSpec specifies what copy of MongoDB to download type DownloadSpec struct { @@ -127,39 +142,39 @@ func parseVersion(version string) ([]int, error) { } func detectPlatform() (string, error) { - switch goOS { + switch GoOS { case "darwin": return "osx", nil case "linux": return "linux", nil default: - return "", &UnsupportedSystemError{msg: "your platform, " + goOS + ", is not supported"} + return "", &UnsupportedSystemError{msg: "your platform, " + GoOS + ", is not supported"} } } func detectArch() (string, error) { - switch goArch { + switch GoArch { case "amd64": return "x86_64", nil default: - return "", &UnsupportedSystemError{msg: "your architecture, " + goArch + ", is not supported"} + return "", &UnsupportedSystemError{msg: "your architecture, " + GoArch + ", is not supported"} } } func detectOSName(mongoVersion []int) string { - if goOS != "linux" { + if GoOS != "linux" { // Not on Linux return "" } - osRelease, osReleaseErr := osrelease.ReadFile(etcOsRelease) + osRelease, osReleaseErr := osrelease.ReadFile(EtcOsRelease) if osReleaseErr == nil { return osNameFromOsRelease(osRelease, mongoVersion) } // We control etcRedhatRelease //nolint:gosec - redhatRelease, redhatReleaseErr := ioutil.ReadFile(etcRedhatRelease) + redhatRelease, redhatReleaseErr := ioutil.ReadFile(EtcRedhatRelease) if redhatReleaseErr == nil { return osNameFromRedhatRelease(string(redhatRelease)) } diff --git a/mongobin/downloadSpec_test.go b/mongobin/downloadSpec_test.go index 96ec4d6..e9f6d8b 100644 --- a/mongobin/downloadSpec_test.go +++ b/mongobin/downloadSpec_test.go @@ -1,10 +1,26 @@ -package mongobin +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mongobin_test import ( "runtime" "testing" "github.com/stretchr/testify/require" + "github.com/tryvium-travels/memongo/mongobin" ) const testMongoVersion = "4.0.5" @@ -16,13 +32,13 @@ func TestMakeDownloadSpec(t *testing.T) { goOs string goArch string - expectedSpec *DownloadSpec + expectedSpec *mongobin.DownloadSpec expectedError string }{ "mac and older mongo": { goOs: "darwin", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "osx", SSLBuildNeeded: true, @@ -34,7 +50,7 @@ func TestMakeDownloadSpec(t *testing.T) { goOs: "darwin", mongoVersion: "4.2.1", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "4.2.1", Platform: "osx", SSLBuildNeeded: false, @@ -50,7 +66,7 @@ func TestMakeDownloadSpec(t *testing.T) { "ubuntu 18.10": { etcFolder: "ubuntu1810", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -61,7 +77,7 @@ func TestMakeDownloadSpec(t *testing.T) { "ubuntu 18.04": { etcFolder: "ubuntu1804", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -73,7 +89,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "4.0.0", etcFolder: "ubuntu1804", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "4.0.0", Platform: "linux", SSLBuildNeeded: false, @@ -85,7 +101,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.2.6", etcFolder: "ubuntu1804", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.2.6", Platform: "linux", SSLBuildNeeded: false, @@ -96,7 +112,7 @@ func TestMakeDownloadSpec(t *testing.T) { "ubuntu 16.04": { etcFolder: "ubuntu1604", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -108,7 +124,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.2.6", etcFolder: "ubuntu1604", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.2.6", Platform: "linux", SSLBuildNeeded: false, @@ -119,7 +135,7 @@ func TestMakeDownloadSpec(t *testing.T) { "ubuntu 14.04": { etcFolder: "ubuntu1404", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -130,7 +146,7 @@ func TestMakeDownloadSpec(t *testing.T) { "SUSE 12": { etcFolder: "suse12", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -141,7 +157,7 @@ func TestMakeDownloadSpec(t *testing.T) { "RHEL 7": { etcFolder: "rhel7", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -152,7 +168,7 @@ func TestMakeDownloadSpec(t *testing.T) { "RHEL 6": { etcFolder: "rhel6", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -163,7 +179,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Debian stretch": { etcFolder: "debianstretch", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -175,7 +191,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.6.4", etcFolder: "debianstretch", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.6.4", Platform: "linux", SSLBuildNeeded: false, @@ -187,7 +203,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.2.7", etcFolder: "debianstretch", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.2.7", Platform: "linux", SSLBuildNeeded: false, @@ -198,7 +214,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Debian jessie": { etcFolder: "debianjessie", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -210,7 +226,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.2.7", etcFolder: "debianjessie", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.2.7", Platform: "linux", SSLBuildNeeded: false, @@ -221,7 +237,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Amazon Linux": { etcFolder: "amazon", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -232,7 +248,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Amazon Linux 2": { etcFolder: "amazon2", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -244,7 +260,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion: "3.6.5", etcFolder: "amazon2", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.6.5", Platform: "linux", SSLBuildNeeded: false, @@ -255,7 +271,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Old Debian": { etcFolder: "old-debian", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -266,7 +282,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Old RedHat": { etcFolder: "old-redhat", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -277,7 +293,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Old SUSE": { etcFolder: "old-sles", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -288,7 +304,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Old Ubuntu": { etcFolder: "old-ubuntu", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -299,7 +315,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Other Linux": { etcFolder: "other-linux", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -310,7 +326,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Empty /etc": { etcFolder: "empty-etc", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -321,7 +337,7 @@ func TestMakeDownloadSpec(t *testing.T) { "Malformed ubuntu": { etcFolder: "ubuntu-malformed", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: testMongoVersion, Platform: "linux", SSLBuildNeeded: false, @@ -343,7 +359,7 @@ func TestMakeDownloadSpec(t *testing.T) { etcFolder: "ubuntu1804", mongoVersion: "4.2.3", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "4.2.3", Platform: "linux", SSLBuildNeeded: false, @@ -354,7 +370,7 @@ func TestMakeDownloadSpec(t *testing.T) { "MongoDB 3.6": { mongoVersion: "3.6.1", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.6.1", Platform: "linux", SSLBuildNeeded: false, @@ -365,7 +381,7 @@ func TestMakeDownloadSpec(t *testing.T) { "MongoDB 3.4": { mongoVersion: "3.4.0", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.4.0", Platform: "linux", SSLBuildNeeded: false, @@ -376,7 +392,7 @@ func TestMakeDownloadSpec(t *testing.T) { "MongoDB 3.2": { mongoVersion: "3.2.0", - expectedSpec: &DownloadSpec{ + expectedSpec: &mongobin.DownloadSpec{ Version: "3.2.0", Platform: "linux", SSLBuildNeeded: false, @@ -424,30 +440,30 @@ func TestMakeDownloadSpec(t *testing.T) { for testName, test := range tests { t.Run(testName, func(t *testing.T) { if test.etcFolder == "" { - etcOsRelease = "./testdata/etc/empty-etc/os-release" - etcRedhatRelease = "./testdata/etc/empty-etc/redhat-release" + mongobin.EtcOsRelease = "./testdata/etc/empty-etc/os-release" + mongobin.EtcRedhatRelease = "./testdata/etc/empty-etc/redhat-release" } else { - etcOsRelease = "./testdata/etc/" + test.etcFolder + "/os-release" - etcRedhatRelease = "./testdata/etc/" + test.etcFolder + "/redhat-release" + mongobin.EtcOsRelease = "./testdata/etc/" + test.etcFolder + "/os-release" + mongobin.EtcRedhatRelease = "./testdata/etc/" + test.etcFolder + "/redhat-release" } if test.goArch == "" { - goArch = "amd64" + mongobin.GoArch = "amd64" } else { - goArch = test.goArch + mongobin.GoArch = test.goArch } if test.goOs == "" { - goOS = "linux" + mongobin.GoOS = "linux" } else { - goOS = test.goOs + mongobin.GoOS = test.goOs } defer func() { - etcOsRelease = "/etc/os-release" - etcRedhatRelease = "/etc/redhat-release" - goOS = runtime.GOOS - goArch = runtime.GOARCH + mongobin.EtcOsRelease = "/etc/os-release" + mongobin.EtcRedhatRelease = "/etc/redhat-release" + mongobin.GoOS = runtime.GOOS + mongobin.GoArch = runtime.GOARCH }() mongoVersion := test.mongoVersion @@ -455,7 +471,7 @@ func TestMakeDownloadSpec(t *testing.T) { mongoVersion = testMongoVersion } - result, err := MakeDownloadSpec(mongoVersion) + result, err := mongobin.MakeDownloadSpec(mongoVersion) if test.expectedError != "" { require.Error(t, err) diff --git a/mongobin/downloadURL.go b/mongobin/downloadURL.go index 3ad31d9..e45e356 100644 --- a/mongobin/downloadURL.go +++ b/mongobin/downloadURL.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mongobin import "fmt" diff --git a/mongobin/downloadURL_test.go b/mongobin/downloadURL_test.go index 34a1f51..c7fdaef 100644 --- a/mongobin/downloadURL_test.go +++ b/mongobin/downloadURL_test.go @@ -1,4 +1,19 @@ -package mongobin +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mongobin_test import ( "net/http" @@ -6,6 +21,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/tryvium-travels/memongo/mongobin" ) // Change this to true to issue a HEAD request in each test to make @@ -20,13 +36,13 @@ func TestGetDownloadURL(t *testing.T) { } tests := map[string]struct { - spec *DownloadSpec + spec *mongobin.DownloadSpec mongoVersions []string expectedURL string }{ "mac-ssl": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "osx", Arch: "x86_64", OSName: "", @@ -38,7 +54,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-VERSION.tgz", }, "mac": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "osx", Arch: "x86_64", OSName: "", @@ -49,7 +65,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-VERSION.tgz", }, "ubuntu 18.04": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "ubuntu1804", @@ -58,7 +74,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-VERSION.tgz", }, "ubuntu 16.04": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "ubuntu1604", @@ -69,7 +85,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-VERSION.tgz", }, "ubuntu 14.04": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "ubuntu1404", @@ -80,7 +96,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-VERSION.tgz", }, "SUSE 12": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "suse12", @@ -89,7 +105,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse12-VERSION.tgz", }, "RHEL 7": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "rhel70", @@ -98,7 +114,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-VERSION.tgz", }, "RHEL 6": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "rhel62", @@ -107,7 +123,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-VERSION.tgz", }, "Debian stretch": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "debian92", @@ -118,7 +134,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-VERSION.tgz", }, "Debian jessie": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "debian81", @@ -129,7 +145,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-VERSION.tgz", }, "Amazon Linux": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "amazon", @@ -138,7 +154,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-VERSION.tgz", }, "Amazon Linux 2": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "amazon2", @@ -149,7 +165,7 @@ func TestGetDownloadURL(t *testing.T) { expectedURL: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon2-VERSION.tgz", }, "Other Linux": { - spec: &DownloadSpec{ + spec: &mongobin.DownloadSpec{ Platform: "linux", Arch: "x86_64", OSName: "", @@ -164,7 +180,7 @@ func TestGetDownloadURL(t *testing.T) { for testName, test := range tests { for _, mongoVersion := range test.mongoVersions { t.Run(testName+"_"+mongoVersion, func(t *testing.T) { - spec := &DownloadSpec{ + spec := &mongobin.DownloadSpec{ Version: mongoVersion, Platform: test.spec.Platform, Arch: test.spec.Arch, diff --git a/mongobin/errors.go b/mongobin/errors.go index 1e4d979..9e8f325 100644 --- a/mongobin/errors.go +++ b/mongobin/errors.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mongobin // UnsupportedSystemError is used to indicate that memongo does not support diff --git a/mongobin/getOrDownload.go b/mongobin/getOrDownload.go index ef3fac0..ea36d9b 100644 --- a/mongobin/getOrDownload.go +++ b/mongobin/getOrDownload.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mongobin import ( @@ -14,14 +29,14 @@ import ( "strings" "time" - "github.com/benweissmann/memongo/memongolog" "github.com/spf13/afero" + "github.com/tryvium-travels/memongo/memongolog" ) -var afs afero.Afero +var Afs afero.Afero func init() { - afs = afero.Afero{ + Afs = afero.Afero{ Fs: afero.NewOsFs(), } } @@ -40,7 +55,7 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log mongodPath := path.Join(dirPath, "mongod") // Check the cache - existsInCache, existsErr := afs.Exists(mongodPath) + existsInCache, existsErr := Afs.Exists(mongodPath) if existsErr != nil { return "", fmt.Errorf("error while checking for mongod in cache: %s", existsErr) } @@ -60,13 +75,13 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log } defer resp.Body.Close() - tgzTempFile, tmpFileErr := afs.TempFile("", "") + tgzTempFile, tmpFileErr := Afs.TempFile("", "") if tmpFileErr != nil { return "", fmt.Errorf("error creating temp file for tarball: %s", tmpFileErr) } defer func() { _ = tgzTempFile.Close() - _ = afs.Remove(tgzTempFile.Name()) + _ = Afs.Remove(tgzTempFile.Name()) }() _, copyErr := io.Copy(tgzTempFile, resp.Body) @@ -101,14 +116,14 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log } } - mkdirErr := afs.MkdirAll(path.Dir(mongodPath), 0755) + mkdirErr := Afs.MkdirAll(path.Dir(mongodPath), 0755) if mkdirErr != nil { return "", fmt.Errorf("error creating directory %s: %s", path.Dir(mongodPath), mkdirErr) } // Extract to a temp file first, then copy to the destination, so we get // atomic behavior if there's multiple parallel downloaders - mongodTmpFile, tmpFileErr := afs.TempFile("", "") + mongodTmpFile, tmpFileErr := Afs.TempFile("", "") if tmpFileErr != nil { return "", fmt.Errorf("error creating temp file for mongod: %s", tmpFileErr) } @@ -123,12 +138,12 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log _ = mongodTmpFile.Close() - chmodErr := afs.Chmod(mongodTmpFile.Name(), 0755) + chmodErr := Afs.Chmod(mongodTmpFile.Name(), 0755) if chmodErr != nil { return "", fmt.Errorf("error chmod-ing mongodb binary at %s: %s", mongodTmpFile, chmodErr) } - renameErr := afs.Rename(mongodTmpFile.Name(), mongodPath) + renameErr := Afs.Rename(mongodTmpFile.Name(), mongodPath) if renameErr != nil { return "", fmt.Errorf("error writing mongod binary from %s to %s: %s", mongodTmpFile.Name(), mongodPath, renameErr) } diff --git a/mongobin/getOrDownload_test.go b/mongobin/getOrDownload_test.go index 19860d2..b533d21 100644 --- a/mongobin/getOrDownload_test.go +++ b/mongobin/getOrDownload_test.go @@ -1,46 +1,62 @@ -package mongobin +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mongobin_test import ( "testing" - "github.com/benweissmann/memongo/memongolog" "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tryvium-travels/memongo/memongolog" + "github.com/tryvium-travels/memongo/mongobin" ) func TestGetOrDownload(t *testing.T) { - afs = afero.Afero{Fs: afero.NewMemMapFs()} + mongobin.Afs = afero.Afero{Fs: afero.NewMemMapFs()} - spec := DownloadSpec{ + spec := mongobin.DownloadSpec{ Version: "4.0.5", Platform: "osx", SSLBuildNeeded: true, Arch: "x86_64", } - cacheDir, err := afs.TempDir("", "") + cacheDir, err := mongobin.Afs.TempDir("", "") require.NoError(t, err) // First call should download the file - path, err := GetOrDownloadMongod(spec.GetDownloadURL(), cacheDir, memongolog.New(nil, memongolog.LogLevelDebug)) + path, err := mongobin.GetOrDownloadMongod(spec.GetDownloadURL(), cacheDir, memongolog.New(nil, memongolog.LogLevelDebug)) require.NoError(t, err) assert.Equal(t, cacheDir+"/mongodb-osx-ssl-x86_64-4_0_5_tgz_d50ef2155b/mongod", path) - stat, err := afs.Stat(path) + stat, err := mongobin.Afs.Stat(path) require.NoError(t, err) assert.True(t, stat.Size() > 50000000) assert.True(t, stat.Mode()&0100 != 0) // Second call should used the cached file - path2, err := GetOrDownloadMongod(spec.GetDownloadURL(), cacheDir, memongolog.New(nil, memongolog.LogLevelDebug)) + path2, err := mongobin.GetOrDownloadMongod(spec.GetDownloadURL(), cacheDir, memongolog.New(nil, memongolog.LogLevelDebug)) require.NoError(t, err) assert.Equal(t, path, path2) - stat2, err := afs.Stat(path2) + stat2, err := mongobin.Afs.Stat(path2) require.NoError(t, err) assert.Equal(t, stat.ModTime(), stat2.ModTime()) diff --git a/monitor/main.go b/monitor/main.go deleted file mode 100644 index 5f3821a..0000000 --- a/monitor/main.go +++ /dev/null @@ -1,21 +0,0 @@ -package monitor - -import ( - "fmt" - "os/exec" -) - -// RunMonitor runs a subprocess that kills the given child pid when the -// parent pid exits. -func RunMonitor(parent int, child int) (*exec.Cmd, error) { - // monitorScript returns a safe script; it's parameterized only by integers - //nolint:gosec - cmd := exec.Command("/bin/sh", "-c", monitorScript(parent, child)) - - err := cmd.Start() - if err != nil { - return nil, fmt.Errorf("Error starting watcher process: %s", err) - } - - return cmd, nil -} diff --git a/monitor/monitor.go b/monitor/monitor.go new file mode 100644 index 0000000..64bd3a4 --- /dev/null +++ b/monitor/monitor.go @@ -0,0 +1,36 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package monitor + +import ( + "fmt" + "os/exec" +) + +// RunMonitor runs a subprocess that kills the given child pid when the +// parent pid exits. +func RunMonitor(parent int, child int) (*exec.Cmd, error) { + // monitorScript returns a safe script; it's parameterized only by integers + //nolint:gosec + cmd := exec.Command("/bin/sh", "-c", monitorScript(parent, child)) + + err := cmd.Start() + if err != nil { + return nil, fmt.Errorf("Error starting watcher process: %s", err) + } + + return cmd, nil +} diff --git a/monitor/main_test.go b/monitor/monitor_test.go similarity index 52% rename from monitor/main_test.go rename to monitor/monitor_test.go index da30d3f..3583e67 100644 --- a/monitor/main_test.go +++ b/monitor/monitor_test.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package monitor import ( diff --git a/monitor/script.go b/monitor/script.go index 886b5aa..910eba0 100644 --- a/monitor/script.go +++ b/monitor/script.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package monitor import "fmt" diff --git a/random.go b/random.go index bff51d0..16077c5 100644 --- a/random.go +++ b/random.go @@ -1,3 +1,18 @@ +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package memongo import ( diff --git a/random_test.go b/random_test.go index 67c9f74..12515e5 100644 --- a/random_test.go +++ b/random_test.go @@ -1,17 +1,33 @@ -package memongo +// Copyright 2021 Tryvium Travels LTD +// Copyright 2019-2020 Ben Weissmann +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package memongo_test import ( "testing" "github.com/stretchr/testify/assert" + "github.com/tryvium-travels/memongo" ) func TestRandomDatabase(t *testing.T) { - s := RandomDatabase() + s := memongo.RandomDatabase() - assert.Len(t, s, DBNameLen) + assert.Len(t, s, memongo.DBNameLen) - dbNameRunes := []rune(DBNameChars) + dbNameRunes := []rune(memongo.DBNameChars) for _, c := range s { assert.Contains(t, dbNameRunes, c) } @@ -21,7 +37,7 @@ func TestRandomDatabaseEntropy(t *testing.T) { seen := map[string]bool{} for i := 0; i < 1000; i++ { - s := RandomDatabase() + s := memongo.RandomDatabase() assert.False(t, seen[s]) seen[s] = true diff --git a/vagrant/amazon/Vagrantfile b/vagrant/amazon/Vagrantfile deleted file mode 100644 index 7f17d8c..0000000 --- a/vagrant/amazon/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "realreadme/amazon2016.09" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/amazon2/Vagrantfile b/vagrant/amazon2/Vagrantfile deleted file mode 100644 index 887f68c..0000000 --- a/vagrant/amazon2/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "aibax/amazonlinux2" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/debian81/Vagrantfile b/vagrant/debian81/Vagrantfile deleted file mode 100644 index bf061f6..0000000 --- a/vagrant/debian81/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "debian/jessie64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/debian92/Vagrantfile b/vagrant/debian92/Vagrantfile deleted file mode 100644 index 201fd5e..0000000 --- a/vagrant/debian92/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "debian/stretch64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/rhel62/Vagrantfile b/vagrant/rhel62/Vagrantfile deleted file mode 100644 index e30d1d6..0000000 --- a/vagrant/rhel62/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "generic/rhel6" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/rhel70/Vagrantfile b/vagrant/rhel70/Vagrantfile deleted file mode 100644 index 9e8ee64..0000000 --- a/vagrant/rhel70/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "generic/rhel7" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/suse12/Vagrantfile b/vagrant/suse12/Vagrantfile deleted file mode 100644 index 03d0647..0000000 --- a/vagrant/suse12/Vagrantfile +++ /dev/null @@ -1,72 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "suse/sles12sp1" - config.vm.synced_folder ".", "/vagrant", disabled: true - - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/ubuntu1404/Vagrantfile b/vagrant/ubuntu1404/Vagrantfile deleted file mode 100644 index b30bded..0000000 --- a/vagrant/ubuntu1404/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "ubuntu/trusty64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/ubuntu1604/Vagrantfile b/vagrant/ubuntu1604/Vagrantfile deleted file mode 100644 index 2b04c9e..0000000 --- a/vagrant/ubuntu1604/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "ubuntu/xenial64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/ubuntu1804/Vagrantfile b/vagrant/ubuntu1804/Vagrantfile deleted file mode 100644 index d697238..0000000 --- a/vagrant/ubuntu1804/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "ubuntu/bionic64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/vagrant/ubuntu1810/Vagrantfile b/vagrant/ubuntu1810/Vagrantfile deleted file mode 100644 index d818094..0000000 --- a/vagrant/ubuntu1810/Vagrantfile +++ /dev/null @@ -1,70 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "generic/ubuntu1810" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end