├── .circleci └── config.yml ├── .gitignore ├── DCO.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── config.go ├── config_test.go ├── docker-compose.yml ├── go.mod ├── go.sum ├── handlers_test.go ├── img └── logo.png ├── main.go ├── nginx ├── mime.types └── nginx.conf ├── repojson ├── primary.sqlite.bz2 ├── primary.sqlite.xz ├── repojson.go └── repojson_test.go └── scripts └── settings.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/golang:latest 6 | working_directory: /go/src/github.com/FINRAOS/yum-nginx-api 7 | environment: 8 | TEST_RESULTS: /tmp/test-results 9 | steps: 10 | - setup_remote_docker 11 | - run: git clone https://github.com/FINRAOS/yum-nginx-api.git -b $CIRCLE_BRANCH . 12 | - run: 13 | shell: /bin/bash 14 | command: | 15 | mkdir -p $TEST_RESULTS 16 | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.34.1 17 | go get -u golang.org/x/lint/golint 18 | go get github.com/jstemmer/go-junit-report 19 | make lint 20 | make test | go-junit-report > ${TEST_RESULTS}/go-test-report.xml 21 | - run: 22 | shell: /bin/bash 23 | command: | 24 | make build 25 | make docker 26 | - run: 27 | shell: /bin/bash 28 | command: | 29 | docker login -u $DOCKER_USER -p $DOCKER_PASS 30 | docker push finraos/yum-nginx-api:latest 31 | - store_test_results: 32 | path: /tmp/test-results 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | .vscode 14 | yumapi* 15 | repodata 16 | *.rpm 17 | *.sqlite -------------------------------------------------------------------------------- /DCO.md: -------------------------------------------------------------------------------- 1 | **Contributions require sign-off. The sign-off is required for all patch or pull requests, which certifies the following agreement given below.** 2 | 3 | Contributor Agreement 4 | --------------------- 5 | 6 | By making a contribution to this project, I certify that: 7 | 8 | (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or 9 | 10 | (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or 11 | 12 | (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. 13 | 14 | (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. 15 | 16 | (e) I also agree to the following terms and conditions: 17 | 18 | (1) Grant of Copyright License. Subject to the terms and conditions of this agreement, You hereby grant to the maintainer and to recipients of software distributed by the maintainer 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 your contributions and such derivative works. 19 | 20 | (2) Grant of Patent License. Subject to the terms and conditions of this agreement, You hereby grant to the maintainer and to recipients of software distributed by the maintainer 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 you that are necessarily infringed by your contribution(s) alone or by combination of your contribution(s) with the work to which such contribution(s) was submitted. If any entity institutes patent litigation against you or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your contribution, or the work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this agreement for that contribution or work shall terminate as of the date such litigation is filed. 21 | 22 | Committing 23 | ---------- 24 | 25 | Add a line stating 26 | 27 | Signed-off-by: Random J Developer 28 | 29 | When committing using the command line you can sign off using the --signoff or -s flag. This adds a Signed-off-by line by the committer at the end of the commit log message. 30 | 31 | git commit -s -m "Commit message" 32 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | MAINTAINER Tim Marcinowski 3 | 4 | RUN yum -y update 5 | RUN yum install -y createrepo && yum clean all 6 | RUN mkdir -p /repo 7 | ADD ./yumapi.yaml / 8 | ADD ./yumapi / 9 | 10 | EXPOSE 8080 11 | 12 | CMD ["/yumapi"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PACKAGE_NAME:='yumapi' 2 | BUILT_ON:=$(shell date) 3 | COMMIT_HASH:=$(shell git log -n 1 --pretty=format:"%H") 4 | PACKAGES:=$(shell go list ./... | grep -v /vendor/) 5 | LDFLAGS:='-s -w -X "main.builtOn=$(BUILT_ON)" -X "main.commitHash=$(COMMIT_HASH)"' 6 | 7 | default: docker 8 | 9 | test: 10 | go test -cover -v $(PACKAGES) 11 | 12 | update-deps: 13 | go get -u ./... 14 | go mod tidy 15 | 16 | gofmt: 17 | go fmt ./... 18 | 19 | lint: gofmt 20 | $(GOPATH)/bin/golint $(PACKAGES) 21 | $(GOPATH)/bin/golangci-lint run 22 | 23 | run: config 24 | go run -ldflags $(LDFLAGS) `find . | grep -v 'test\|vendor\|repo' | grep \.go` 25 | 26 | # Cross-compile from OS X to Linux using xgo 27 | cc: 28 | xgo --targets=linux/amd64 -ldflags $(LDFLAGS) -out $(PACKAGE_NAME) . 29 | mv -f yumapi-* yumapi 30 | 31 | # Build on Linux 32 | build: 33 | CGO_ENABLED=0 go build -ldflags $(LDFLAGS) -a -o $(PACKAGE_NAME) . 34 | 35 | clean: 36 | rm -rf yumapi* coverage.out coverage-all.out repodata *.rpm *.sqlite 37 | 38 | config: 39 | printf "upload_dir: .\ndev_mode: true" > yumapi.yaml 40 | 41 | docker: 42 | printf "upload_dir: /repo\n" > yumapi.yaml 43 | docker build -t finraos/yum-nginx-api:latest . 44 | 45 | # Run just API without NGINX 46 | drun: 47 | docker run -d -p 8080:8080 --name yumapi finraos/yum-nginx-api 48 | 49 | compose: 50 | docker-compose up -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | drawing 2 | 3 | A GO API for managing yum repos and NGINX to serve them 4 | ======= 5 | 6 | [![CircleCI](https://circleci.com/gh/FINRAOS/yum-nginx-api/tree/master.svg?style=svg)](https://circleci.com/gh/FINRAOS/yum-nginx-api/tree/master) [![Go Report Card](https://goreportcard.com/badge/github.com/FINRAOS/yum-nginx-api)](https://goreportcard.com/report/github.com/FINRAOS/yum-nginx-api) 7 | 8 | [yum-nginx-api][1] is a go API for uploading RPMs to yum repositories and also configurations for running NGINX to serve them. 9 | 10 | It is a deployable solution with Docker or a single 8MB statically linked Linux binary. yum-nginx-api enables CI tools to be used for uploading RPMs and managing yum repositories. 11 | 12 | Included in this project is a go package `repojson` that can be used to read a repodata directory and return a JSON array of all packages in the primary.sqlite.(bz2|xz). For usage go to [RepoJSON](#repojson) 13 | 14 | **Problems solved with this project**: 15 | 16 | 1. Serves updates to Red Hat / CentOS *really fast* and easily scalable. 17 | 2. Limited options for a self-service yum repository to engineers via an API. 18 | 3. Continuous Integration (CI) tools like Jenkins can build, sync, and promote yum repositories with this project unlike Red Hat Satellite Server and Spacewalk. 19 | 4. Poor documentation on installing a yum repository with NGINX. 20 | 21 | **Requirements**: 22 | 23 | 1. Server (Bare-metal/VM) 24 | 2. [NGINX][2] 25 | 3. [Go][3] >= 1.9.1 (Optional) 26 | 4. [xgo][4] (Optional) 27 | 5. [Docker][5] >=17.09/1.32 (Optional) 28 | 6. [Docker Compose][6] >=1.16.1 (Optional) 29 | 30 | 31 | ## Run only API 32 | 33 | docker run -d -p 8080:8080 --name yumapi finraos/yum-nginx-api 34 | 35 | ## Run Docker Compose 36 | 37 | docker-compose up 38 | 39 | ## How to build yum-nginx-api (Go & Docker) 40 | 41 | # This projects needs CGO if not on Linux 42 | git clone https://github.com/FINRAOS/yum-nginx-api.git 43 | cd yum-nginx-api 44 | make build # Linux only 45 | make cc # OS X only 46 | make docker 47 | 48 | ## How to Install yum-nginx-api (Binary) 49 | 50 | make build # Linux only 51 | make cc # OS X only 52 | 53 | ## Configuration File `yumapi.yaml` 54 | 55 | **Configuration file can be JSON, TOML, YAML, HCL, or Java properties** 56 | 57 | # createrepo workers, default is 2 58 | createrepo_workers: 59 | # http max content upload, default is 10000000 <- 10MB 60 | max_content_length: 61 | # yum repo directory, default is ./ 62 | upload_dir: 63 | # port to run http server, default is 8080 64 | port: 65 | # max retries to retry failed createrepo, default is 3 66 | max_retries: 67 | 68 | ## API Usage 69 | 70 | **Post binary RPM to API endpoint:** 71 | 72 | curl -F file=@yobot-4.6.2.noarch.rpm http://localhost:8080/api/upload 73 | 74 | **List repo contents package name, arch, version and summary:** 75 | 76 | curl http://localhost:8080/api/repo 77 | 78 | **Successful post:** 79 | 80 | [{ 81 | "name": "yobot", 82 | "arch": "x86_64", 83 | "version": "4.6.2", 84 | "summary": "Shenandoah RPM" 85 | },{ 86 | "name": "yum-nginx-api-test", 87 | "arch": "x86_64", 88 | "version": "0.1", 89 | "summary": "Yum NGINX API Test RPM" 90 | }] 91 | 92 | **Health check API endpoint** 93 | 94 | curl http://localhost/api/health 95 | 96 | ## RepoJSON 97 | 98 | package main 99 | 100 | import ( 101 | "encoding/json" 102 | "fmt" 103 | 104 | "github.com/FINRAOS/yum-nginx-api/repojson" 105 | ) 106 | 107 | func main() { 108 | ar, err := repojson.RepoJSON("./") 109 | if err != nil { 110 | fmt.Println(err) 111 | } 112 | js, err := json.Marshal(ar) 113 | if err != nil { 114 | fmt.Println(err) 115 | } 116 | fmt.Println(string(js)) 117 | } 118 | 119 | ## Contributing & Sponsor 120 | 121 | More information on how to contribute to this project including sign off and the [DCO agreement](https://github.com/FINRAOS/yum-nginx-api/blob/master/DCO.md), please see the project's [GitHub wiki](https://github.com/FINRAOS/yum-nginx-api/wiki) for more information. 122 | 123 | FINRA has graciously allocated time for their internal development resources to enhance yum-nginx-api and encourages participation in the open source community. Want to join FINRA? Please visit [http://technology.finra.org/careers.html](http://technology.finra.org/careers.html). 124 | 125 | [FINRA Technology](http://technology.finra.org/) 126 | 127 | ## License Type 128 | 129 | yum-nginx-api project is licensed under [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) 130 | 131 | [1]: https://github.com/finraos/yum-nginx-api/wiki 132 | [2]: https://nginx.org 133 | [3]: https://golang.org 134 | [4]: https://github.com/karalabe/xgo 135 | [5]: https://docs.docker.com/engine/installation/ 136 | [6]: https://docs.docker.com/compose/install/ 137 | -------------------------------------------------------------------------------- /config.go: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2014 yum-nginx-api Contributors. 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // http://www.apache.org/licenses/LICENSE-2.0 6 | // Unless required by applicable law or agreed to in writing, software 7 | // distributed under the License is distributed on an "AS IS" BASIS, 8 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | // See the License for the specific language governing permissions and 10 | // limitations under the License. 11 | 12 | package main 13 | 14 | import ( 15 | "errors" 16 | "os" 17 | "path" 18 | 19 | "github.com/FINRAOS/yum-nginx-api/repojson" 20 | "github.com/spf13/viper" 21 | ) 22 | 23 | const ( 24 | crError = "config: createrepo_workers is less than 1" 25 | mlError = "config: max_content_length is less than 1MB" 26 | upError = "config: upload_directory does not exist" 27 | ptError = "config: port is not above port 80" 28 | mxError = "config: max_retries is less than 1" 29 | ) 30 | 31 | // Some vars are used with different types in handlers vs validation 32 | var ( 33 | builtOn string 34 | commitHash string 35 | createRepo string 36 | maxLength int64 37 | uploadDir string 38 | port string 39 | devMode bool 40 | maxRetries int 41 | crCtr int64 42 | crPaths = [2]string{"/bin/createrepo", "/usr/bin/createrepo"} 43 | rJSON []repojson.Repo 44 | crBin string 45 | ) 46 | 47 | // Validate configurations and if createrepo binary is present in path 48 | func configValidate() error { 49 | viper.SetConfigName("yumapi") 50 | viper.AddConfigPath("/opt/yum-nginx-api/yumapi/") 51 | viper.AddConfigPath("/etc/yumapi/") 52 | viper.AddConfigPath(".") 53 | err := viper.ReadInConfig() 54 | if err != nil { 55 | return errors.New("Fatal error config file: " + err.Error()) 56 | } 57 | 58 | viper.SetDefault("createrepo_workers", 1) 59 | viper.SetDefault("max_content_length", 10000000) 60 | viper.SetDefault("upload_dir", "./") 61 | viper.SetDefault("port", 8080) 62 | viper.SetDefault("dev_mode", false) 63 | viper.SetDefault("max_retries", 3) 64 | 65 | createRepo = viper.GetString("createrepo_workers") 66 | maxLength = viper.GetInt64("max_content_length") 67 | uploadDir = path.Clean(viper.GetString("upload_dir")) + "/" 68 | port = viper.GetString("port") 69 | devMode = viper.GetBool("dev_mode") 70 | maxRetries = viper.GetInt("max_retries") 71 | 72 | if viper.GetInt64("createrepo_workers") < 1 { 73 | return errors.New(crError) 74 | } 75 | if maxLength < 1000000 { 76 | return errors.New(mlError) 77 | } 78 | if _, err := os.Stat(uploadDir); os.IsNotExist(err) { 79 | return errors.New(upError) 80 | } 81 | if viper.GetInt64("port") < 80 { 82 | return errors.New(ptError) 83 | } 84 | if maxRetries < 1 { 85 | return errors.New(mxError) 86 | } 87 | if !devMode { 88 | for _, cr := range crPaths { 89 | if _, err := os.Stat(cr); !os.IsNotExist(err) { 90 | crBin = cr 91 | break 92 | } 93 | } 94 | if crBin == "" { 95 | return errors.New(crError) 96 | } 97 | } 98 | return nil 99 | } 100 | -------------------------------------------------------------------------------- /config_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | const testFile = "./yumapi.yaml" 10 | 11 | // TestConfigValidate validates all configuration 12 | // options in yumapi config file 13 | func TestConfigValidate(t *testing.T) { 14 | b := []byte("upload_dir: .\ncreaterepo_workers: 2\ndev_mode: true\nmax_content_length: 220000000\nport: 80\nmax_retries: 1") 15 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 16 | t.Fatalf("Error writing file") 17 | } 18 | if err := configValidate(); err != nil { 19 | os.Remove(testFile) 20 | t.Fatal(err) 21 | } 22 | os.Remove(testFile) 23 | } 24 | 25 | // TestConfigCR verifies error returned for zero workers 26 | func TestConfigCR(t *testing.T) { 27 | b := []byte("createrepo_workers: 0") 28 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 29 | t.Fatalf("Error writing file") 30 | } 31 | if err := configValidate(); err.Error() != crError { 32 | os.Remove(testFile) 33 | t.Fatal(err) 34 | } 35 | os.Remove(testFile) 36 | } 37 | 38 | // TestConfigML verifies max_content_length is not too low 39 | func TestConfigML(t *testing.T) { 40 | b := []byte("max_content_length: 900000") 41 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 42 | t.Fatalf("Error writing file") 43 | } 44 | if err := configValidate(); err.Error() != mlError { 45 | os.Remove(testFile) 46 | t.Fatal(err) 47 | } 48 | os.Remove(testFile) 49 | } 50 | 51 | // TestConfigUp verifies upload_dir does not exist 52 | func TestConfigUP(t *testing.T) { 53 | b := []byte("upload_dir: /supp") 54 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 55 | t.Fatalf("Error writing file") 56 | } 57 | if err := configValidate(); err.Error() != upError { 58 | os.Remove(testFile) 59 | t.Fatal(err) 60 | } 61 | os.Remove(testFile) 62 | } 63 | 64 | // TestConfigPT verifies ports under 80 are not allowed 65 | func TestConfigPT(t *testing.T) { 66 | b := []byte("port: 22") 67 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 68 | t.Fatalf("Error writing file") 69 | } 70 | if err := configValidate(); err.Error() != ptError { 71 | os.Remove(testFile) 72 | t.Fatal(err) 73 | } 74 | os.Remove(testFile) 75 | } 76 | 77 | // TestConfigMX verifies max retries are not less than 1 78 | func TestConfigMX(t *testing.T) { 79 | b := []byte("max_retries: 0") 80 | if err := ioutil.WriteFile(testFile, b, 0644); err != nil { 81 | t.Fatalf("Error writing file") 82 | } 83 | if err := configValidate(); err.Error() != mxError { 84 | os.Remove(testFile) 85 | t.Fatal(err) 86 | } 87 | os.Remove(testFile) 88 | } 89 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | container_name: nginx 5 | image: nginx:latest 6 | volumes: 7 | - ./nginx/nginx.conf:/etc/nginx/nginx.conf 8 | - ./nginx/mime.types:/etc/nginx/mime.types 9 | - ./:/repo 10 | network_mode: bridge 11 | ports: 12 | - "8000:80" 13 | restart: always 14 | links: 15 | - yumapi 16 | yumapi: 17 | container_name: yumapi 18 | image: finraos/yum-nginx-api:latest 19 | network_mode: bridge 20 | restart: always 21 | volumes: 22 | - ./:/repo 23 | ports: 24 | - "8080:8080" 25 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/FINRAOS/yum-nginx-api 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/fsnotify/fsnotify v1.4.9 // indirect 7 | github.com/go-ozzo/ozzo-routing v2.1.4+incompatible 8 | github.com/golang/gddo v0.0.0-20201222204913-17b648fae295 // indirect 9 | github.com/h2non/filetype v1.1.0 10 | github.com/magiconair/properties v1.8.4 // indirect 11 | github.com/mitchellh/mapstructure v1.4.0 // indirect 12 | github.com/mutecomm/go-sqlcipher v0.0.0-20170920224653-f799951b4ab2 13 | github.com/pelletier/go-toml v1.8.1 // indirect 14 | github.com/spf13/afero v1.5.1 // indirect 15 | github.com/spf13/cast v1.3.1 // indirect 16 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 17 | github.com/spf13/pflag v1.0.5 // indirect 18 | github.com/spf13/viper v1.7.1 19 | github.com/ulikunitz/xz v0.5.9 20 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect 21 | golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect 22 | golang.org/x/text v0.3.4 // indirect 23 | gopkg.in/ini.v1 v1.62.0 // indirect 24 | gopkg.in/yaml.v2 v2.4.0 // indirect 25 | ) 26 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.16.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 4 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 5 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 6 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 7 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 8 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 9 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 10 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 11 | cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= 12 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 13 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 14 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 15 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 16 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 17 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 18 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 19 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 20 | github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= 21 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 22 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 23 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 24 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 25 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 26 | github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= 27 | github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= 28 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 29 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 30 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 31 | github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 32 | github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 33 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 34 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 35 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 36 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 37 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 38 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 39 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 40 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 41 | github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 42 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 43 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 44 | github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= 45 | github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= 46 | github.com/garyburd/redigo v1.1.1-0.20170914051019-70e1b1943d4f/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= 47 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 48 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 49 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 50 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 51 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 52 | github.com/go-ozzo/ozzo-routing v2.1.4+incompatible h1:gQmNyAwMnBHr53Nma2gPTfVVc6i2BuAwCWPam2hIvKI= 53 | github.com/go-ozzo/ozzo-routing v2.1.4+incompatible/go.mod h1:hvoxy5M9SJaY0viZvcCsODidtUm5CzRbYKEWuQpr+2A= 54 | github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 55 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 56 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 57 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 58 | github.com/golang/gddo v0.0.0-20201222204913-17b648fae295 h1:yQgx8q21QCDNsw9YAnTMh7O7zpRAhUsgbgPwLrCnY0s= 59 | github.com/golang/gddo v0.0.0-20201222204913-17b648fae295/go.mod h1:ijRvpgDJDI262hYq/IQVYgf8hd8IHUs93Ol0kvMBAx4= 60 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 61 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 62 | github.com/golang/lint v0.0.0-20170918230701-e5d664eb928e/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= 63 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 64 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 65 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 66 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 67 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 68 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 69 | github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 70 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 71 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 72 | github.com/google/go-cmp v0.1.1-0.20171103154506-982329095285/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 73 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 74 | github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= 75 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 76 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 77 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 78 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 79 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 80 | github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= 81 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 82 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 83 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 84 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 85 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 86 | github.com/gregjones/httpcache v0.0.0-20170920190843-316c5e0ff04e/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= 87 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 88 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 89 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 90 | github.com/h2non/filetype v1.1.0 h1:Or/gjocJrJRNK/Cri/TDEKFjAR+cfG6eK65NGYB6gBA= 91 | github.com/h2non/filetype v1.1.0/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= 92 | github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= 93 | github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= 94 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 95 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 96 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 97 | github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 98 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 99 | github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= 100 | github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= 101 | github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= 102 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 103 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 104 | github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= 105 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 106 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 107 | github.com/hashicorp/hcl v0.0.0-20170914154624-68e816d1c783/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= 108 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 109 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 110 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 111 | github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= 112 | github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= 113 | github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= 114 | github.com/inconshreveable/log15 v0.0.0-20170622235902-74a0988b5f80/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o= 115 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 116 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 117 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 118 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 119 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 120 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 121 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 122 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 123 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 124 | github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= 125 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 126 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 127 | github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= 128 | github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 129 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 130 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 131 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 132 | github.com/magiconair/properties v1.7.4-0.20170902060319-8d7837e64d3c/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 133 | github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 134 | github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY= 135 | github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= 136 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 137 | github.com/mattn/go-colorable v0.0.10-0.20170816031813-ad5389df28cd/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 138 | github.com/mattn/go-isatty v0.0.2/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 139 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 140 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 141 | github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= 142 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 143 | github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 144 | github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 145 | github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= 146 | github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= 147 | github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 148 | github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 149 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 150 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 151 | github.com/mitchellh/mapstructure v1.4.0 h1:7ks8ZkOP5/ujthUsT07rNv+nkLXCQWKNHuwzOAesEks= 152 | github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 153 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 154 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 155 | github.com/mutecomm/go-sqlcipher v0.0.0-20170920224653-f799951b4ab2 h1:Q5L04ENac5Rx1K+vuxM7cjsrCgqSJNumYy3SHOQC4ec= 156 | github.com/mutecomm/go-sqlcipher v0.0.0-20170920224653-f799951b4ab2/go.mod h1:S9Hougr2LhvUtZGY1fCTj9nr9P53lfsCCQ2XqVMFZX8= 157 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 158 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 159 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 160 | github.com/pelletier/go-toml v1.0.1-0.20170904195809-1d6b12b7cb29/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 161 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 162 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 163 | github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= 164 | github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= 165 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 166 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 167 | github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= 168 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 169 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 170 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 171 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 172 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 173 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 174 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 175 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 176 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 177 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 178 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 179 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 180 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 181 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 182 | github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 183 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 184 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 185 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= 186 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 187 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= 188 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 189 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 190 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 191 | github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 192 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 193 | github.com/spf13/afero v1.5.1 h1:VHu76Lk0LSP1x254maIu2bplkWpfBWI+B+6fdoZprcg= 194 | github.com/spf13/afero v1.5.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= 195 | github.com/spf13/cast v1.1.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= 196 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 197 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 198 | github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= 199 | github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 200 | github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 201 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 202 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 203 | github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= 204 | github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= 205 | github.com/spf13/pflag v1.0.1-0.20170901120850-7aff26db30c1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 206 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 207 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 208 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 209 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 210 | github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= 211 | github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= 212 | github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= 213 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 214 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 215 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 216 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 217 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 218 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 219 | github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= 220 | github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= 221 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 222 | github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= 223 | github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= 224 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 225 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 226 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 227 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 228 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 229 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 230 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 231 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 232 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 233 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 234 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 235 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 236 | golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 237 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 238 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 239 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 240 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 241 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 242 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 243 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 244 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 245 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 246 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 247 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 248 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 249 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 250 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 251 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 252 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 253 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 254 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 255 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 256 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 257 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 258 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 259 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 260 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 261 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 262 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 263 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 264 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 265 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 266 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 267 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 268 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 269 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= 270 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 271 | golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 272 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 273 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 274 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 275 | golang.org/x/sync v0.0.0-20170517211232-f52d1811a629/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 276 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 277 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 278 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 279 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 280 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 281 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 282 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 283 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 284 | golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 285 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 286 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 287 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 288 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 289 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 290 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 291 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 292 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 293 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 294 | golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 295 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 296 | golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 h1:/dSxr6gT0FNI1MO5WLJo8mTmItROeOKTkDn+7OwWBos= 297 | golang.org/x/sys v0.0.0-20210105210732-16f7687f5001/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 298 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 299 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 300 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 301 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 302 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 303 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 304 | golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= 305 | golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 306 | golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 307 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 308 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 309 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 310 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 311 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 312 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 313 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 314 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 315 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 316 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 317 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 318 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 319 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 320 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 321 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 322 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 323 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 324 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 325 | golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 326 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 327 | google.golang.org/api v0.0.0-20170921000349-586095a6e407/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= 328 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 329 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 330 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 331 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 332 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 333 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 334 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 335 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 336 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 337 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 338 | google.golang.org/genproto v0.0.0-20170918111702-1e559d0a00ee/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 339 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 340 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 341 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 342 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 343 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 344 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 345 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 346 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 347 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 348 | google.golang.org/grpc v1.2.1-0.20170921194603-d4b75ebd4f9f/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 349 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 350 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 351 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 352 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 353 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 354 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 355 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 356 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 357 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 358 | gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= 359 | gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 360 | gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= 361 | gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 362 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 363 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 364 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 365 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 366 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 367 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 368 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 369 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 370 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 371 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 372 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 373 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 374 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 375 | -------------------------------------------------------------------------------- /handlers_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | 8 | "github.com/go-ozzo/ozzo-routing" 9 | "github.com/go-ozzo/ozzo-routing/content" 10 | ) 11 | 12 | func newRouter() *routing.Router { 13 | rtr := routing.New() 14 | rtr.Group("/api", content.TypeNegotiator(content.JSON)) 15 | return rtr 16 | } 17 | func testHealthHandler(t *testing.T, rtr *routing.Router) { 18 | rtr.Get("/health", healthRoute) 19 | req, err := http.NewRequest("GET", "/health", nil) 20 | req.Header.Set("Content-Type", "application/json") 21 | if err != nil { 22 | t.Fatal(err) 23 | } 24 | 25 | rr := httptest.NewRecorder() 26 | rtr.ServeHTTP(rr, req) 27 | if status := rr.Code; status != http.StatusOK { 28 | t.Errorf("handler returned wrong status code: got %v want %v", 29 | status, http.StatusOK) 30 | } 31 | 32 | expected := `OK` 33 | if rr.Body.String() != expected { 34 | t.Errorf("handler returned unexpected body: got %v want %v", 35 | rr.Body.String(), expected) 36 | } 37 | } 38 | 39 | func testRepoHandler(t *testing.T, rtr *routing.Router) { 40 | rtr.Get("/repo", repoRoute) 41 | req, err := http.NewRequest("GET", "/repo", nil) 42 | req.Header.Set("Content-Type", "application/json") 43 | if err != nil { 44 | t.Fatal(err) 45 | } 46 | 47 | rr := httptest.NewRecorder() 48 | rtr.ServeHTTP(rr, req) 49 | if status := rr.Code; status != http.StatusOK { 50 | t.Errorf("handler returned wrong status code: got %v want %v", 51 | status, http.StatusOK) 52 | } 53 | 54 | expected := `[]` 55 | if rr.Body.String() != expected { 56 | t.Errorf("handler returned unexpected body: got %v want %v", 57 | rr.Body.String(), expected) 58 | } 59 | } 60 | 61 | func TestHealth(t *testing.T) { 62 | testHealthHandler(t, newRouter()) 63 | } 64 | 65 | func TestRepo(t *testing.T) { 66 | testRepoHandler(t, newRouter()) 67 | } 68 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FINRAOS/yum-nginx-api/20a93611878c253ed40e5bed73ebb9b81d8b4130/img/logo.png -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2014 yum-nginx-api Contributors. 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // http://www.apache.org/licenses/LICENSE-2.0 6 | // Unless required by applicable law or agreed to in writing, software 7 | // distributed under the License is distributed on an "AS IS" BASIS, 8 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | // See the License for the specific language governing permissions and 10 | // limitations under the License. 11 | 12 | package main 13 | 14 | import ( 15 | "io" 16 | "io/ioutil" 17 | "log" 18 | "net/http" 19 | "os" 20 | "os/exec" 21 | "time" 22 | 23 | "github.com/FINRAOS/yum-nginx-api/repojson" 24 | routing "github.com/go-ozzo/ozzo-routing" 25 | "github.com/go-ozzo/ozzo-routing/access" 26 | "github.com/go-ozzo/ozzo-routing/content" 27 | "github.com/go-ozzo/ozzo-routing/fault" 28 | "github.com/go-ozzo/ozzo-routing/slash" 29 | "github.com/h2non/filetype" 30 | ) 31 | 32 | // crRoutine is a simple buffer to not overload the system 33 | // by running too many createrepo system commands, uncompress, 34 | // and sqlite connections at the same time 35 | func crRoutine() { 36 | for { 37 | if crCtr > 0 { 38 | for i := 0; i < maxRetries; i++ { 39 | crExec := exec.Command(crBin, "--update", "--workers", createRepo, uploadDir) 40 | _, err := crExec.Output() 41 | if err != nil { 42 | log.Println("Unable to execute createrepo ", err) 43 | } else { 44 | rJSON, err = repojson.RepoJSON(uploadDir) 45 | if err != nil { 46 | log.Println(err) 47 | } 48 | crCtr-- 49 | break 50 | } 51 | time.Sleep(1 * time.Second) 52 | } 53 | } 54 | time.Sleep(3 * time.Second) 55 | } 56 | } 57 | 58 | // uploadRoute function for handler /upload 59 | func uploadRoute(c *routing.Context) error { 60 | err := c.Request.ParseMultipartForm(maxLength) 61 | if err != nil { 62 | c.Response.WriteHeader(http.StatusInternalServerError) 63 | _ = c.Write("Upload Failed " + err.Error()) 64 | return err 65 | } 66 | file, handler, err := c.Request.FormFile("file") 67 | if err != nil { 68 | c.Response.WriteHeader(http.StatusInternalServerError) 69 | _ = c.Write("Upload Failed " + err.Error()) 70 | return err 71 | } 72 | defer file.Close() 73 | filePath := uploadDir + handler.Filename 74 | f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0644) 75 | if err != nil { 76 | c.Response.WriteHeader(http.StatusInternalServerError) 77 | _ = c.Write("Upload Failed " + err.Error()) 78 | return err 79 | } 80 | defer f.Close() 81 | _, err = io.Copy(f, file) 82 | if err != nil { 83 | c.Response.WriteHeader(http.StatusInternalServerError) 84 | _ = c.Write("Upload Failed " + err.Error()) 85 | return err 86 | } 87 | buf, _ := ioutil.ReadFile(filePath) 88 | if kind, err := filetype.Match(buf); err != nil || kind.MIME.Value != "application/x-rpm" { 89 | err := os.Remove(filePath) 90 | if err != nil { 91 | log.Println("Unable to delete " + filePath) 92 | } 93 | c.Response.WriteHeader(http.StatusUnsupportedMediaType) 94 | return c.Write(handler.Filename + " not RPM") 95 | } 96 | // If not in development mode increment create-repo counter 97 | // for command to be ran by go routine crRoutine 98 | if !devMode { 99 | crCtr++ 100 | } 101 | c.Response.WriteHeader(http.StatusAccepted) 102 | return c.Write("Uploaded") 103 | } 104 | 105 | // healthRoute function for handler /health 106 | func healthRoute(c *routing.Context) error { 107 | c.Response.Header().Add("Version", commitHash) 108 | return c.Write("OK") 109 | } 110 | 111 | // repoRoute function for handler /repo 112 | func repoRoute(c *routing.Context) error { 113 | return c.Write(rJSON) 114 | } 115 | 116 | func main() { 117 | if err := configValidate(); err != nil { 118 | log.Fatalln(err.Error()) 119 | } 120 | go crRoutine() 121 | rtr := routing.New() 122 | 123 | api := rtr.Group("/api", 124 | fault.Recovery(log.Printf), 125 | slash.Remover(http.StatusMovedPermanently), 126 | content.TypeNegotiator(content.JSON)) 127 | 128 | // Disable logging on health endpoints 129 | api.Get("/health", healthRoute) 130 | api.Use(access.Logger(log.Printf)) 131 | api.Post("/upload", uploadRoute) 132 | api.Get("/repo", repoRoute) 133 | 134 | http.Handle("/", rtr) 135 | log.Printf("yumapi built-on %s, version %s started on %s \n", builtOn, commitHash, port) 136 | err := http.ListenAndServe(":"+port, nil) 137 | if err != nil { 138 | log.Panicln(err) 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /nginx/mime.types: -------------------------------------------------------------------------------- 1 | types { 2 | text/html html htm shtml; 3 | text/css css; 4 | text/xml xml; 5 | image/gif gif; 6 | image/jpeg jpeg jpg; 7 | application/x-javascript js; 8 | application/atom+xml atom; 9 | application/rss+xml rss; 10 | 11 | text/mathml mml; 12 | text/plain txt; 13 | text/vnd.sun.j2me.app-descriptor jad; 14 | text/vnd.wap.wml wml; 15 | text/x-component htc; 16 | 17 | image/png png; 18 | image/tiff tif tiff; 19 | image/vnd.wap.wbmp wbmp; 20 | image/x-icon ico; 21 | image/x-jng jng; 22 | image/x-ms-bmp bmp; 23 | image/svg+xml svg svgz; 24 | image/webp webp; 25 | 26 | application/java-archive jar war ear; 27 | application/mac-binhex40 hqx; 28 | application/msword doc; 29 | application/pdf pdf; 30 | application/postscript ps eps ai; 31 | application/rtf rtf; 32 | application/vnd.ms-excel xls; 33 | application/vnd.ms-powerpoint ppt; 34 | application/vnd.wap.wmlc wmlc; 35 | application/vnd.google-earth.kml+xml kml; 36 | application/vnd.google-earth.kmz kmz; 37 | application/x-7z-compressed 7z; 38 | application/x-cocoa cco; 39 | application/x-java-archive-diff jardiff; 40 | application/x-java-jnlp-file jnlp; 41 | application/x-makeself run; 42 | application/x-perl pl pm; 43 | application/x-pilot prc pdb; 44 | application/x-rar-compressed rar; 45 | application/x-redhat-package-manager rpm; 46 | application/x-sea sea; 47 | application/x-shockwave-flash swf; 48 | application/x-stuffit sit; 49 | application/x-tcl tcl tk; 50 | application/x-x509-ca-cert der pem crt; 51 | application/x-xpinstall xpi; 52 | application/xhtml+xml xhtml; 53 | application/zip zip; 54 | application/x-bzip2 bz2; 55 | application/x-tar tar; 56 | application/x-gzip gz tgz; 57 | 58 | application/octet-stream bin exe dll; 59 | application/octet-stream deb; 60 | application/octet-stream dmg; 61 | application/octet-stream eot; 62 | application/octet-stream iso img; 63 | application/octet-stream msi msp msm; 64 | 65 | audio/midi mid midi kar; 66 | audio/mpeg mp3; 67 | audio/ogg ogg; 68 | audio/x-m4a m4a; 69 | audio/x-realaudio ra; 70 | 71 | video/3gpp 3gpp 3gp; 72 | video/mp4 mp4; 73 | video/mpeg mpeg mpg; 74 | video/quicktime mov; 75 | video/webm webm; 76 | video/x-flv flv; 77 | video/x-m4v m4v; 78 | video/x-mng mng; 79 | video/x-ms-asf asx asf; 80 | video/x-ms-wmv wmv; 81 | video/x-msvideo avi; 82 | } 83 | -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes auto; 3 | worker_rlimit_nofile 65536; 4 | 5 | error_log /var/log/nginx/error.log; 6 | 7 | pid /var/run/nginx.pid; 8 | 9 | events { 10 | worker_connections 8192; 11 | multi_accept on; 12 | use epoll; 13 | } 14 | 15 | http { 16 | include /etc/nginx/mime.types; 17 | default_type application/octet-stream; 18 | log_format main '$time_iso8601 [$remote_addr] [$request_time ms] $request ' 19 | '$status $body_bytes_sent "$http_user_agent"'; 20 | 21 | access_log /var/log/nginx/access.log main; 22 | 23 | server_tokens off; 24 | sendfile off; 25 | tcp_nopush on; 26 | keepalive_timeout 300; 27 | keepalive_requests 100000; 28 | tcp_nodelay off; 29 | reset_timedout_connection on; 30 | 31 | open_file_cache max=200000 inactive=5m; 32 | open_file_cache_valid 5m; 33 | open_file_cache_min_uses 2; 34 | open_file_cache_errors off; 35 | 36 | gzip on; 37 | gzip_http_version 1.1; 38 | gzip_comp_level 5; 39 | gzip_min_length 10000; 40 | gzip_proxied any; 41 | gzip_vary on; 42 | gzip_types 43 | application/json 44 | application/xml 45 | application/x-redhat-package-manager 46 | text/plain 47 | text/x-component; 48 | 49 | server { 50 | listen 80; 51 | server_name localhost; 52 | client_max_body_size 900m; 53 | location / { 54 | root /repo; 55 | autoindex on; 56 | expires modified +90d; 57 | } 58 | 59 | location = /favicon.ico { 60 | log_not_found off; 61 | access_log off; 62 | } 63 | 64 | location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe) { 65 | log_not_found off; 66 | access_log off; 67 | } 68 | 69 | location = /404.html { 70 | log_not_found off; 71 | access_log off; 72 | } 73 | 74 | location = /robots.txt { 75 | deny all; 76 | log_not_found off; 77 | access_log off; 78 | } 79 | 80 | location = /(.git|.svn|README.md) { 81 | deny all; 82 | log_not_found off; 83 | access_log off; 84 | } 85 | 86 | location /api { 87 | try_files $uri @api; 88 | } 89 | 90 | location @api { 91 | proxy_pass http://yumapi:8080; 92 | proxy_redirect off; 93 | proxy_buffering off; 94 | 95 | proxy_set_header Host $host; 96 | proxy_set_header X-Real-IP $remote_addr; 97 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 98 | 99 | proxy_http_version 1.1; 100 | proxy_set_header Upgrade $http_upgrade; 101 | proxy_set_header Connection "Upgrade"; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /repojson/primary.sqlite.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FINRAOS/yum-nginx-api/20a93611878c253ed40e5bed73ebb9b81d8b4130/repojson/primary.sqlite.bz2 -------------------------------------------------------------------------------- /repojson/primary.sqlite.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FINRAOS/yum-nginx-api/20a93611878c253ed40e5bed73ebb9b81d8b4130/repojson/primary.sqlite.xz -------------------------------------------------------------------------------- /repojson/repojson.go: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2014 yum-nginx-api Contributors. 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // http://www.apache.org/licenses/LICENSE-2.0 6 | // Unless required by applicable law or agreed to in writing, software 7 | // distributed under the License is distributed on an "AS IS" BASIS, 8 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | // See the License for the specific language governing permissions and 10 | // limitations under the License. 11 | 12 | package repojson 13 | 14 | import ( 15 | "compress/bzip2" 16 | "database/sql" 17 | "errors" 18 | "io" 19 | "os" 20 | "path/filepath" 21 | "regexp" 22 | 23 | // Bug in mattn/go-sqlite3 and also lighter 24 | _ "github.com/mutecomm/go-sqlcipher" 25 | "github.com/ulikunitz/xz" 26 | ) 27 | 28 | // Repo fields is column names from packages table 29 | // in primary.sqlite file. Other columns not exposed yet 30 | // pkgKey,pkgId,epoch,release,description,url, 31 | // time_file,time_build,rpm_license,rpm_vendor, 32 | // rpm_group,rpm_buildhost,rpm_sourcerpm,rpm_header_start, 33 | // rpm_header_end,rpm_packager,size_package,size_installed, 34 | // size_archive,location_href,location_base,checksum_type 35 | type Repo struct { 36 | Name string `json:"name"` 37 | Arch string `json:"arch"` 38 | Version string `json:"version"` 39 | Summary string `json:"summary"` 40 | } 41 | 42 | // setPsqlite sets string pSqlite by walking 43 | // path given to WalkFunc to find if primary.sqlite 44 | // is present in directory with bzip2 or xz extenstion 45 | func setPsqlite(pSqlite *string) filepath.WalkFunc { 46 | return func(path string, info os.FileInfo, err error) error { 47 | if err != nil { 48 | return nil 49 | } 50 | match, _ := regexp.MatchString("primary.sqlite.(xz|bz2)$", path) 51 | if match { 52 | *pSqlite = path 53 | return nil 54 | } 55 | return nil 56 | } 57 | } 58 | 59 | // extractXZ extracts primary.sqlite xz if exists 60 | func extractXZ(path, pSqlite string) error { 61 | f, err := os.Open(pSqlite) 62 | if err != nil { 63 | return err 64 | } 65 | defer f.Close() 66 | r, err := xz.NewReader(f) 67 | if err != nil { 68 | return err 69 | } 70 | w, err := os.Create(path + "primary.sqlite") 71 | if err != nil { 72 | return err 73 | } 74 | defer w.Close() 75 | if _, err = io.Copy(w, r); err != nil { 76 | return err 77 | } 78 | 79 | return nil 80 | } 81 | 82 | // extractBZ2 extracts primary.sqlite bzip2 if exists 83 | func extractBZ2(path, pSqlite string) error { 84 | f, err := os.Open(pSqlite) 85 | if err != nil { 86 | return err 87 | } 88 | defer f.Close() 89 | r := bzip2.NewReader(f) 90 | if err != nil { 91 | return err 92 | } 93 | w, err := os.Create(path + "primary.sqlite") 94 | if err != nil { 95 | return err 96 | } 97 | defer w.Close() 98 | if _, err = io.Copy(w, r); err != nil { 99 | return err 100 | } 101 | 102 | return nil 103 | } 104 | 105 | // repoSqlite connects to uncompressed sqlite file 106 | // quries database and returns array of Repo objects 107 | func repoSqlite(path string) ([]Repo, error) { 108 | var repo []Repo 109 | db, err := sql.Open("sqlite3", path+"primary.sqlite") 110 | if err != nil { 111 | return nil, err 112 | } 113 | defer db.Close() 114 | sqlStmt := `select name, arch, version, summary from packages;` 115 | rows, err := db.Query(sqlStmt) 116 | if err != nil { 117 | return nil, err 118 | } 119 | defer rows.Close() 120 | for rows.Next() { 121 | r := Repo{} 122 | err = rows.Scan(&r.Name, &r.Arch, &r.Version, &r.Summary) 123 | if err != nil { 124 | return nil, err 125 | } 126 | repo = append(repo, r) 127 | } 128 | return repo, nil 129 | } 130 | 131 | // RepoJSON is main function in repojson package to return 132 | // array of Repo objects 133 | func RepoJSON(path string) ([]Repo, error) { 134 | var ( 135 | extract error 136 | pSqlite string 137 | ) 138 | err := filepath.Walk(path, setPsqlite(&pSqlite)) 139 | if err != nil { 140 | return nil, err 141 | } 142 | if pSqlite != "" { 143 | switch filepath.Ext(pSqlite) { 144 | case ".xz": 145 | extract = extractXZ(path, pSqlite) 146 | case ".bz2": 147 | extract = extractBZ2(path, pSqlite) 148 | } 149 | if extract == nil { 150 | j, err := repoSqlite(path) 151 | if err != nil { 152 | return nil, extract 153 | } 154 | return j, nil 155 | } 156 | return nil, extract 157 | } 158 | return nil, errors.New("RepoJSON: couldn't find a supported primary.sqlite file in " + path) 159 | } 160 | -------------------------------------------------------------------------------- /repojson/repojson_test.go: -------------------------------------------------------------------------------- 1 | package repojson 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "testing" 9 | ) 10 | 11 | const jstring = `[{"name":"yum-nginx-api-test","arch":"x86_64","version":"0.1","summary":"Yum NGINX API Test RPM"}]` 12 | 13 | // TestSetPsqlite finds primary.sqlite archive in current directory 14 | func TestSetPsqlite(t *testing.T) { 15 | var pSqlite string 16 | err := filepath.Walk("./", setPsqlite(&pSqlite)) 17 | if err != nil { 18 | t.Fatalf(err.Error()) 19 | } 20 | if pSqlite == "" { 21 | t.Fatalf("Expected to match file") 22 | } 23 | } 24 | 25 | // TestRegExSetPsqlite tests regex used to find files in given path 26 | func TestRegExSetPsqlite(t *testing.T) { 27 | var pSqlite string 28 | b := []byte("") 29 | if err := ioutil.WriteFile("/tmp/primary.sqlitexz", b, 0644); err != nil { 30 | os.Remove("/tmp/primary.sqlitexz") 31 | t.Fatalf("Error writing file") 32 | } 33 | err := filepath.Walk("/tmp", setPsqlite(&pSqlite)) 34 | if err != nil { 35 | t.Fatalf(err.Error()) 36 | } 37 | if pSqlite != "" { 38 | os.Remove("/tmp/primary.sqlitexz") 39 | t.Fatalf("Expected to not match file got " + pSqlite) 40 | } 41 | os.Remove("/tmp/primary.sqlitexz") 42 | 43 | if err := ioutil.WriteFile("/tmp/primary.sqlite.xzz", b, 0644); err != nil { 44 | os.Remove("/tmp/primary.sqlite.xzz") 45 | t.Fatalf("Error writing file") 46 | } 47 | err = filepath.Walk("/tmp", setPsqlite(&pSqlite)) 48 | if err != nil { 49 | t.Fatalf(err.Error()) 50 | } 51 | if pSqlite != "" { 52 | os.Remove("/tmp/primary.sqlite.xzz") 53 | t.Fatalf("Expected to not match file got " + pSqlite) 54 | } 55 | os.Remove("/tmp/primary.sqlite.xzz") 56 | 57 | if err := ioutil.WriteFile("/tmp/primary.sqlite.bz", b, 0644); err != nil { 58 | os.Remove("/tmp/primary.sqlite.bz") 59 | t.Fatalf("Error writing file") 60 | } 61 | err = filepath.Walk("/tmp", setPsqlite(&pSqlite)) 62 | if err != nil { 63 | t.Fatalf(err.Error()) 64 | } 65 | if pSqlite != "" { 66 | os.Remove("/tmp/primary.sqlite.bz") 67 | t.Fatalf("Expected to not match file got " + pSqlite) 68 | } 69 | os.Remove("/tmp/primary.sqlite.bz") 70 | } 71 | 72 | // TestExtractBZ extracts bzip2 archive and verifies uncompressed 73 | func TestExtractBZ(t *testing.T) { 74 | err := extractBZ2("./", "./primary.sqlite.bz2") 75 | if err != nil { 76 | t.Fatalf("Expected to extract test file") 77 | } 78 | if _, err := os.Stat("./primary.sqlite"); os.IsNotExist(err) { 79 | t.Fatalf("Expected extracted file to exist") 80 | } 81 | os.Remove("./primary.sqlite") 82 | } 83 | 84 | // TestExtractXZ extracts xz archive and verifies uncompressed 85 | 86 | func TestExtractXZ(t *testing.T) { 87 | err := extractXZ("./", "./primary.sqlite.xz") 88 | if err != nil { 89 | t.Fatalf("Expected to extract test file") 90 | } 91 | if _, err := os.Stat("./primary.sqlite"); os.IsNotExist(err) { 92 | t.Fatalf("Expected extracted file to exist") 93 | } 94 | os.Remove("./primary.sqlite") 95 | } 96 | 97 | // TestRepoJSON matches JSON constant to archive 98 | // after it is read from sqlite and marshalled 99 | func TestRepoJSON(t *testing.T) { 100 | var ba []Repo 101 | ba, err := RepoJSON("./") 102 | if err != nil { 103 | os.Remove("primary.sqlite") 104 | t.Fatalf("Expected to find primary.sqlite") 105 | } 106 | js, _ := json.Marshal(ba) 107 | if string(js) != jstring { 108 | t.Fatalf("Expect %s got %s", jstring, string(js)) 109 | } 110 | } 111 | 112 | // TestFailRepoJSON verifies RepoJSON return errors if no match is made 113 | // in directory path 114 | func TestFailRepoJSON(t *testing.T) { 115 | dir, err := ioutil.TempDir("", "yumapi") 116 | if err != nil { 117 | t.Fatalf("Failed to make temp dir") 118 | } 119 | if _, err := RepoJSON(dir); err == nil { 120 | os.Remove("primary.sqlite") 121 | os.RemoveAll(dir) 122 | t.Fatalf("Expected to not find primary.sqlite") 123 | } 124 | os.Remove("primary.sqlite") 125 | os.RemoveAll(dir) 126 | } 127 | -------------------------------------------------------------------------------- /scripts/settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # (C) Copyright 2014 yum-nginx-api Contributors. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | cat << 'LIMITS' > /etc/security/limits.d/nginx-limits.conf 14 | nginx soft nofile 30000 15 | nginx hard nofile 65536 16 | nginx soft nproc 16384 17 | nginx hard nproc 16384 18 | nginx hard stack 1024 19 | LIMITS 20 | 21 | cat << 'SYSCTL' >> /etc/sysctl.d/nginx.conf 22 | fs.file-max=70000 23 | fs.nr_open=70000 24 | net.core.netdev_max_backlog=4096 25 | net.core.rmem_max=16777216 26 | net.core.somaxconn=65535 27 | net.core.wmem_max=16777216 28 | net.ipv4.tcp_fin_timeout=30 29 | net.ipv4.tcp_keepalive_time=30 30 | net.ipv4.tcp_max_syn_backlog=20480 31 | net.ipv4.tcp_max_tw_buckets=400000 32 | net.ipv4.tcp_no_metrics_save=1 33 | net.ipv4.tcp_syn_retries=2 34 | net.ipv4.tcp_synack_retries=2 35 | net.ipv4.tcp_tw_recycle=1 36 | net.ipv4.tcp_tw_reuse=1 37 | vm.min_free_kbytes=65536 38 | vm.overcommit_memory=1 39 | SYSCTL 40 | --------------------------------------------------------------------------------