├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── BUILD ├── LICENSE ├── README.md ├── WORKSPACE ├── docs ├── code-of-conduct.md └── contributing.md ├── gazelle-update-repos ├── git_protocol_v2_handler.go ├── go.mod ├── go.sum ├── goblet-server ├── BUILD └── main.go ├── goblet.go ├── goblet_deps.bzl ├── google ├── BUILD ├── backup.go └── hooks.go ├── http_proxy_server.go ├── io.go ├── managed_repository.go ├── reporting.go └── testing ├── BUILD ├── end2end ├── BUILD └── fetch_test.go └── test_proxy_server.go /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Expected Behavior 2 | 3 | 4 | ## Actual Behavior 5 | 6 | 7 | ## Steps to Reproduce the Problem 8 | 9 | 1. 10 | 1. 11 | 1. 12 | 13 | ## Specifications 14 | 15 | - Version: 16 | - Platform: -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes # 2 | 3 | > It's a good idea to open an issue first for discussion. 4 | 5 | - [ ] Tests pass 6 | - [ ] Appropriate changes to README are included in PR -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /goblet-server/goblet-server 2 | /bazel-* 3 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@bazel_gazelle//:def.bzl", "gazelle") 3 | 4 | # gazelle:prefix github.com/google/goblet 5 | # gazelle:build_file_name BUILD 6 | gazelle(name = "gazelle") 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "git_protocol_v2_handler.go", 12 | "goblet.go", 13 | "http_proxy_server.go", 14 | "io.go", 15 | "managed_repository.go", 16 | "reporting.go", 17 | ], 18 | importpath = "github.com/google/goblet", 19 | visibility = ["//visibility:public"], 20 | deps = [ 21 | "@com_github_go_git_go_git_v5//:go_default_library", 22 | "@com_github_go_git_go_git_v5//plumbing:go_default_library", 23 | "@com_github_google_gitprotocolio//:go_default_library", 24 | "@com_github_grpc_ecosystem_grpc_gateway//runtime:go_default_library", 25 | "@io_opencensus_go//stats:go_default_library", 26 | "@io_opencensus_go//tag:go_default_library", 27 | "@org_golang_google_grpc//codes:go_default_library", 28 | "@org_golang_google_grpc//status:go_default_library", 29 | "@org_golang_x_oauth2//:go_default_library", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Goblet: Git caching proxy 2 | 3 | Goblet is a Git proxy server that caches repositories for read access. Git 4 | clients can configure their repositories to use this as an HTTP proxy server, 5 | and this proxy server serves git-fetch requests if it can be served from the 6 | local cache. 7 | 8 | In the Git protocol, the server creates a pack-file dynamically based on the 9 | objects that the clients have. Because of this, caching Git protocol response 10 | is hard as different client needs a different response. Goblet parses the 11 | content of the HTTP POST requests and tells if the request can be served from 12 | the local cache. 13 | 14 | This is developed to reduce the automation traffic to googlesource.com. Goblet 15 | would be useful if you need to run a Git read-only mirroring server to offload 16 | the traffic. 17 | 18 | This is not an official Google product (i.e. a 20% project). 19 | 20 | ## Usage 21 | 22 | Goblet is intended to be used as a library. You would need to write some glue 23 | code. This repository includes the glue code for googlesource.com. See 24 | `goblet-server` and `google` directories. 25 | 26 | ## Limitations 27 | 28 | Note that Goblet forwards the ls-refs traffic to the upstream server. If the 29 | upstream server is down, Goblet is effectively down. Technically, we can modify 30 | Goblet to serve even if the upstream is down, but the current implementation 31 | doesn't do such thing. 32 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | 3 | http_archive( 4 | name = "io_bazel_rules_go", 5 | sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b", 6 | urls = [ 7 | "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz", 8 | "https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz", 9 | ], 10 | ) 11 | 12 | load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") 13 | 14 | go_rules_dependencies() 15 | 16 | go_register_toolchains(version = "1.16.5") 17 | 18 | http_archive( 19 | name = "bazel_gazelle", 20 | sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f", 21 | urls = [ 22 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz", 23 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz", 24 | ], 25 | ) 26 | 27 | http_archive( 28 | name = "com_google_protobuf", 29 | sha256 = "528927e398f4e290001886894dac17c5c6a2e5548f3fb68004cfb01af901b53a", 30 | strip_prefix = "protobuf-3.17.3", 31 | urls = [ 32 | "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.17.3.zip", 33 | "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.zip", 34 | ], 35 | ) 36 | 37 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 38 | 39 | protobuf_deps() 40 | 41 | load("//:goblet_deps.bzl", "goblet_deps") 42 | 43 | # gazelle:repository_macro goblet_deps.bzl%goblet_deps 44 | goblet_deps() 45 | 46 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") 47 | 48 | gazelle_dependencies() 49 | -------------------------------------------------------------------------------- /docs/code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Google Open Source Community Guidelines 2 | 3 | At Google, we recognize and celebrate the creativity and collaboration of open 4 | source contributors and the diversity of skills, experiences, cultures, and 5 | opinions they bring to the projects and communities they participate in. 6 | 7 | Every one of Google's open source projects and communities are inclusive 8 | environments, based on treating all individuals respectfully, regardless of 9 | gender identity and expression, sexual orientation, disabilities, 10 | neurodiversity, physical appearance, body size, ethnicity, nationality, race, 11 | age, religion, or similar personal characteristic. 12 | 13 | We value diverse opinions, but we value respectful behavior more. 14 | 15 | Respectful behavior includes: 16 | 17 | * Being considerate, kind, constructive, and helpful. 18 | * Not engaging in demeaning, discriminatory, harassing, hateful, sexualized, or 19 | physically threatening behavior, speech, and imagery. 20 | * Not engaging in unwanted physical contact. 21 | 22 | Some Google open source projects [may adopt][] an explicit project code of 23 | conduct, which may have additional detailed expectations for participants. Most 24 | of those projects will use our [modified Contributor Covenant][]. 25 | 26 | [may adopt]: https://opensource.google/docs/releasing/preparing/#conduct 27 | [modified Contributor Covenant]: https://opensource.google/docs/releasing/template/CODE_OF_CONDUCT/ 28 | 29 | ## Resolve peacefully 30 | 31 | We do not believe that all conflict is necessarily bad; healthy debate and 32 | disagreement often yields positive results. However, it is never okay to be 33 | disrespectful. 34 | 35 | If you see someone behaving disrespectfully, you are encouraged to address the 36 | behavior directly with those involved. Many issues can be resolved quickly and 37 | easily, and this gives people more control over the outcome of their dispute. 38 | If you are unable to resolve the matter for any reason, or if the behavior is 39 | threatening or harassing, report it. We are dedicated to providing an 40 | environment where participants feel welcome and safe. 41 | 42 | ## Reporting problems 43 | 44 | Some Google open source projects may adopt a project-specific code of conduct. 45 | In those cases, a Google employee will be identified as the Project Steward, 46 | who will receive and handle reports of code of conduct violations. In the event 47 | that a project hasn’t identified a Project Steward, you can report problems by 48 | emailing opensource@google.com. 49 | 50 | We will investigate every complaint, but you may not receive a direct response. 51 | We will use our discretion in determining when and how to follow up on reported 52 | incidents, which may range from not taking action to permanent expulsion from 53 | the project and project-sponsored spaces. We will notify the accused of the 54 | report and provide them an opportunity to discuss it before any action is 55 | taken. The identity of the reporter will be omitted from the details of the 56 | report supplied to the accused. In potentially harmful situations, such as 57 | ongoing harassment or threats to anyone's safety, we may take action without 58 | notice. 59 | 60 | *This document was adapted from the [IndieWeb Code of Conduct][] and can also 61 | be found at .* 62 | 63 | [IndieWeb Code of Conduct]: https://indieweb.org/code-of-conduct 64 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google/conduct/). 29 | -------------------------------------------------------------------------------- /gazelle-update-repos: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | bazel run //:gazelle -- update-repos -from_file=go.mod -prune=true -to_macro=goblet_deps.bzl%goblet_deps 3 | -------------------------------------------------------------------------------- /git_protocol_v2_handler.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "context" 19 | "io" 20 | "strings" 21 | "time" 22 | 23 | "github.com/go-git/go-git/v5/plumbing" 24 | "github.com/google/gitprotocolio" 25 | "go.opencensus.io/stats" 26 | "go.opencensus.io/tag" 27 | "google.golang.org/grpc/codes" 28 | "google.golang.org/grpc/status" 29 | ) 30 | 31 | const ( 32 | checkFrequency = 1 * time.Second 33 | ) 34 | 35 | type gitProtocolErrorReporter interface { 36 | reportError(context.Context, time.Time, error) 37 | } 38 | 39 | func handleV2Command(ctx context.Context, reporter gitProtocolErrorReporter, repo *managedRepository, command []*gitprotocolio.ProtocolV2RequestChunk, w io.Writer) bool { 40 | startTime := time.Now() 41 | var err error 42 | ctx, err = tag.New(ctx, tag.Upsert(CommandTypeKey, command[0].Command)) 43 | if err != nil { 44 | reporter.reportError(ctx, startTime, err) 45 | return false 46 | } 47 | 48 | cacheState := "locally-served" 49 | ctx, err = tag.New(ctx, tag.Upsert(CommandCacheStateKey, cacheState)) 50 | if err != nil { 51 | reporter.reportError(ctx, startTime, err) 52 | return false 53 | } 54 | switch command[0].Command { 55 | case "ls-refs": 56 | ctx, err = tag.New(ctx, tag.Update(CommandCacheStateKey, "queried-upstream")) 57 | if err != nil { 58 | reporter.reportError(ctx, startTime, err) 59 | return false 60 | } 61 | 62 | resp, err := repo.lsRefsUpstream(command) 63 | if err != nil { 64 | reporter.reportError(ctx, startTime, err) 65 | return false 66 | } 67 | 68 | refs, err := parseLsRefsResponse(resp) 69 | if err != nil { 70 | reporter.reportError(ctx, startTime, err) 71 | return false 72 | } 73 | 74 | if hasUpdate, err := repo.hasAnyUpdate(refs); err != nil { 75 | reporter.reportError(ctx, startTime, err) 76 | return false 77 | } else if hasUpdate { 78 | go repo.fetchUpstream() 79 | } 80 | 81 | writeResp(w, resp) 82 | reporter.reportError(ctx, startTime, nil) 83 | return true 84 | 85 | case "fetch": 86 | wantHashes, wantRefs, err := parseFetchWants(command) 87 | if err != nil { 88 | reporter.reportError(ctx, startTime, err) 89 | return false 90 | } 91 | 92 | if hasAllWants, err := repo.hasAllWants(wantHashes, wantRefs); err != nil { 93 | reporter.reportError(ctx, startTime, err) 94 | return false 95 | } else if !hasAllWants { 96 | ctx, err = tag.New(ctx, tag.Update(CommandCacheStateKey, "queried-upsteam")) 97 | if err != nil { 98 | reporter.reportError(ctx, startTime, err) 99 | return false 100 | } 101 | 102 | fetchStartTime := time.Now() 103 | fetchDone := make(chan error, 1) 104 | go func() { 105 | fetchDone <- repo.fetchUpstream() 106 | }() 107 | timer := time.NewTimer(checkFrequency) 108 | LOOP: 109 | for { 110 | select { 111 | case <-ctx.Done(): 112 | reporter.reportError(ctx, startTime, ctx.Err()) 113 | return false 114 | case err := <-fetchDone: 115 | if hasAllWants, checkErr := repo.hasAllWants(wantHashes, wantRefs); checkErr != nil { 116 | reporter.reportError(ctx, startTime, checkErr) 117 | return false 118 | } else if !hasAllWants { 119 | reporter.reportError(ctx, startTime, err) 120 | return false 121 | } 122 | break LOOP 123 | case <-timer.C: 124 | if hasAllWants, err := repo.hasAllWants(wantHashes, wantRefs); err != nil { 125 | reporter.reportError(ctx, startTime, err) 126 | return false 127 | } else if hasAllWants { 128 | break LOOP 129 | } 130 | timer.Reset(checkFrequency) 131 | } 132 | } 133 | stats.Record(ctx, UpstreamFetchWaitingTime.M(int64(time.Now().Sub(fetchStartTime)/time.Millisecond))) 134 | } 135 | 136 | if err := repo.serveFetchLocal(command, w); err != nil { 137 | reporter.reportError(ctx, startTime, err) 138 | return false 139 | } 140 | reporter.reportError(ctx, startTime, nil) 141 | return true 142 | } 143 | reporter.reportError(ctx, startTime, status.Error(codes.InvalidArgument, "unknown command")) 144 | return false 145 | } 146 | 147 | func parseLsRefsResponse(chunks []*gitprotocolio.ProtocolV2ResponseChunk) (map[string]plumbing.Hash, error) { 148 | m := map[string]plumbing.Hash{} 149 | for _, ch := range chunks { 150 | if ch.Response == nil { 151 | continue 152 | } 153 | ss := strings.Split(string(ch.Response), " ") 154 | if len(ss) < 2 { 155 | return nil, status.Errorf(codes.Internal, "cannot parse the upstream ls-refs response: got %d component, want at least 2", len(ss)) 156 | } 157 | m[strings.TrimSpace(ss[1])] = plumbing.NewHash(ss[0]) 158 | } 159 | return m, nil 160 | } 161 | 162 | func parseFetchWants(chunks []*gitprotocolio.ProtocolV2RequestChunk) ([]plumbing.Hash, []string, error) { 163 | hashes := []plumbing.Hash{} 164 | refs := []string{} 165 | for _, ch := range chunks { 166 | if ch.Argument == nil { 167 | continue 168 | } 169 | s := string(ch.Argument) 170 | if strings.HasPrefix(s, "want ") { 171 | ss := strings.Split(s, " ") 172 | if len(ss) < 2 { 173 | return nil, nil, status.Errorf(codes.InvalidArgument, "cannot parse the fetch request: got %d component, want at least 2", len(ss)) 174 | } 175 | hashes = append(hashes, plumbing.NewHash(strings.TrimSpace(ss[1]))) 176 | } else if strings.HasPrefix(s, "want-ref ") { 177 | ss := strings.Split(s, " ") 178 | if len(ss) < 2 { 179 | return nil, nil, status.Errorf(codes.InvalidArgument, "cannot parse the fetch request: got %d component, want at least 2", len(ss)) 180 | } 181 | refs = append(refs, strings.TrimSpace(ss[1])) 182 | } 183 | } 184 | return hashes, refs, nil 185 | } 186 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/goblet 2 | 3 | go 1.12 4 | 5 | require ( 6 | cloud.google.com/go v0.86.0 7 | cloud.google.com/go/logging v1.4.2 8 | cloud.google.com/go/storage v1.16.0 9 | contrib.go.opencensus.io/exporter/stackdriver v0.13.1 10 | github.com/Microsoft/go-winio v0.5.0 // indirect 11 | github.com/ProtonMail/go-crypto v0.0.0-20210705153151-cc34b1f6908b // indirect 12 | github.com/aws/aws-sdk-go v1.30.7 // indirect 13 | github.com/go-git/go-git/v5 v5.4.2 14 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 15 | github.com/google/gitprotocolio v0.0.0-20210704173409-b5a56823ae52 16 | github.com/google/uuid v1.1.2 17 | github.com/grpc-ecosystem/grpc-gateway v1.16.0 18 | github.com/kevinburke/ssh_config v1.1.0 // indirect 19 | github.com/sergi/go-diff v1.2.0 // indirect 20 | go.opencensus.io v0.23.0 21 | golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect 22 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 23 | golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 24 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect 25 | google.golang.org/api v0.50.0 26 | google.golang.org/genproto v0.0.0-20210708141623-e76da96a951f 27 | google.golang.org/grpc v1.39.0 28 | ) 29 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 5 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 6 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 7 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 8 | cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= 9 | cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= 10 | cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= 11 | cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= 12 | cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= 13 | cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= 14 | cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= 15 | cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= 16 | cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= 17 | cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= 18 | cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= 19 | cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= 20 | cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= 21 | cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= 22 | cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= 23 | cloud.google.com/go v0.86.0 h1:Lo1JDRwMOAxQxTQcbGXi4p60jyMoXNpkmzzzL2Agt5k= 24 | cloud.google.com/go v0.86.0/go.mod h1:YG2MRW8zzPSZaztnTZtxbMPK2VYaHg4NTDYZMG+5ZqQ= 25 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 26 | cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= 27 | cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= 28 | cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= 29 | cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= 30 | cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA= 31 | cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= 32 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 33 | cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ= 34 | cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= 35 | cloud.google.com/go/logging v1.4.2 h1:Mu2Q75VBDQlW1HlBMjTX4X84UFR73G1TiLlRYc/b7tA= 36 | cloud.google.com/go/logging v1.4.2/go.mod h1:jco9QZSx8HiVVqLJReq7z7bVdj0P1Jb9PDFs63T+axo= 37 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 38 | cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= 39 | cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= 40 | cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU= 41 | cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= 42 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 43 | cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= 44 | cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= 45 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 46 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= 47 | cloud.google.com/go/storage v1.16.0 h1:1UwAux2OZP4310YXg5ohqBEpV16Y93uZG4+qOX7K2Kg= 48 | cloud.google.com/go/storage v1.16.0/go.mod h1:ieKBmUyzcftN5tbxwnXClMKH00CfcQ+xL6NN0r5QfmE= 49 | contrib.go.opencensus.io/exporter/stackdriver v0.13.1 h1:RX9W6FelAqTVnBi/bRXJLXr9n18v4QkQwZYIdnNS51I= 50 | contrib.go.opencensus.io/exporter/stackdriver v0.13.1/go.mod h1:z2tyTZtPmQ2HvWH4cOmVDgtY+1lomfKdbLnkJvZdc8c= 51 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY= 52 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 53 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 54 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 55 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= 56 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 57 | github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= 58 | github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= 59 | github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= 60 | github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 61 | github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= 62 | github.com/ProtonMail/go-crypto v0.0.0-20210705153151-cc34b1f6908b h1:BF5p87XWvmgdrTPPzcRMwC0TMQbviwQ+uBKfNfWJy50= 63 | github.com/ProtonMail/go-crypto v0.0.0-20210705153151-cc34b1f6908b/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= 64 | github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= 65 | github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= 66 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= 67 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= 68 | github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= 69 | github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= 70 | github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= 71 | github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= 72 | github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 73 | github.com/aws/aws-sdk-go v1.30.7 h1:IaXfqtioP6p9SFAnNfsqdNczbR5UNbYqvcZUSsCAdTY= 74 | github.com/aws/aws-sdk-go v1.30.7/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= 75 | github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= 76 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 77 | github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= 78 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 79 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= 80 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 81 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= 82 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 83 | github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= 84 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 85 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 86 | github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 87 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M= 88 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 89 | github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed h1:OZmjad4L3H8ncOIR8rnb5MREYqG8ixi5+WbeUsquF0c= 90 | github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 91 | github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= 92 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 93 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 94 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 95 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 96 | github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= 97 | github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= 98 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 99 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 100 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 101 | github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= 102 | github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 103 | github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 104 | github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0 h1:dulLQAYQFYtG5MTplgNGHWuV2D+OBD+Z8lmDBmbLg+s= 105 | github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= 106 | github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= 107 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 108 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= 109 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 110 | github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= 111 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 112 | github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= 113 | github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= 114 | github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= 115 | github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= 116 | github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= 117 | github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= 118 | github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= 119 | github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= 120 | github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= 121 | github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= 122 | github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= 123 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0= 124 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 125 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 126 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I= 127 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 128 | github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= 129 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 130 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 131 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 132 | github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 133 | github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 134 | github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 135 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= 136 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 137 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 138 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 139 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 140 | github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 141 | github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 142 | github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 143 | github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= 144 | github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= 145 | github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= 146 | github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= 147 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 148 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 149 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 150 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 151 | github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 152 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 153 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 154 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 155 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 156 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 157 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 158 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 159 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 160 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 161 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 162 | github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= 163 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 164 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 165 | github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= 166 | github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 167 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 168 | github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= 169 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 170 | github.com/google/gitprotocolio v0.0.0-20210704173409-b5a56823ae52 h1:/a887PZoXM9aLYwXS2ufq+Gnr5KUg5gm8gBoxKjnQuo= 171 | github.com/google/gitprotocolio v0.0.0-20210704173409-b5a56823ae52/go.mod h1:O2KL6wjnwAu7+dPSZhhrjp35gFdyoHlP/f6dhc9YupY= 172 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 173 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 174 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 175 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 176 | github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 177 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 178 | github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 179 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 180 | github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 181 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 182 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 183 | github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= 184 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 185 | github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= 186 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 187 | github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 188 | github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 189 | github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= 190 | github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= 191 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 192 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 193 | github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 194 | github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 195 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 196 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 197 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 198 | github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 199 | github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 200 | github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 201 | github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 202 | github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 203 | github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9 h1:2tft2559dNwKl2znYB58oVTql0grRB+Ml3LWIBbc4WM= 204 | github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 205 | github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= 206 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 207 | github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= 208 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 209 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 210 | github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= 211 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 212 | github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= 213 | github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= 214 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 215 | github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= 216 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 217 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 218 | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= 219 | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 220 | github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= 221 | github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 222 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= 223 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= 224 | github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= 225 | github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= 226 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 227 | github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= 228 | github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= 229 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 230 | github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= 231 | github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= 232 | github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= 233 | github.com/kevinburke/ssh_config v1.1.0 h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o= 234 | github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= 235 | github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= 236 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 237 | github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= 238 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 239 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 240 | github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= 241 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 242 | github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= 243 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 244 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 245 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 246 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 247 | github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= 248 | github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= 249 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 250 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 251 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= 252 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 253 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 254 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 255 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 256 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 257 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 258 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= 259 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 260 | github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= 261 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= 262 | github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk= 263 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 264 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 265 | github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= 266 | github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 267 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 268 | github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= 269 | github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 270 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 271 | github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= 272 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 273 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 274 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 275 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 276 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 277 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 278 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 279 | github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= 280 | github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= 281 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 282 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 283 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 284 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 285 | github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs= 286 | github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 287 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 288 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 289 | go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA= 290 | go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 291 | go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 292 | go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 293 | go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= 294 | go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= 295 | go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= 296 | go.opentelemetry.io/proto/otlp v0.7.0 h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8= 297 | go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= 298 | golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 299 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 300 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 301 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 302 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 303 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 304 | golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 305 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 306 | golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= 307 | golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 308 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 309 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 310 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 311 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 312 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 313 | golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 314 | golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 315 | golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 316 | golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= 317 | golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y= 318 | golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= 319 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 320 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4= 321 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 322 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 323 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 324 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 325 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 326 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 327 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 328 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 329 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= 330 | golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 331 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 332 | golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 333 | golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= 334 | golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 335 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 336 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= 337 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 338 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 339 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 340 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 341 | golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 342 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 343 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 344 | golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 345 | golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 346 | golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= 347 | golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 348 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 349 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 350 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 351 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 352 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 353 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 354 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 355 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 356 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 357 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 358 | golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 359 | golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 360 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 361 | golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 362 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 363 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 364 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 365 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 366 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 367 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 368 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 369 | golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 370 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 371 | golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 372 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 373 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 374 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 375 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 376 | golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 377 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 378 | golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 379 | golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 380 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 381 | golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= 382 | golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= 383 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= 384 | golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 385 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= 386 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 387 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 388 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 389 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 390 | golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 391 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 392 | golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 393 | golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 394 | golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 395 | golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 396 | golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 397 | golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 398 | golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 399 | golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 400 | golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 401 | golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8= 402 | golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 403 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 404 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 405 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 406 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 407 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 408 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 409 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 410 | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 411 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 412 | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 413 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= 414 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 415 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 416 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 417 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 418 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 419 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 420 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 421 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 422 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 423 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 424 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 425 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 426 | golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 427 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 428 | golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 429 | golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 430 | golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 431 | golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 432 | golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 433 | golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 434 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 435 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 436 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 437 | golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 438 | golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 439 | golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 440 | golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 441 | golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 442 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 443 | golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 444 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 445 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 446 | golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 447 | golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 448 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 449 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 450 | golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 451 | golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 452 | golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 453 | golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 454 | golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 455 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 456 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 457 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 458 | golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 459 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 460 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 461 | golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 462 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 463 | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 464 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= 465 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 466 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= 467 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 468 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 469 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 470 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 471 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 472 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 473 | golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 474 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 475 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 476 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 477 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 478 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 479 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= 480 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 481 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 482 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 483 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 484 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 485 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 486 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 487 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 488 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 489 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 490 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 491 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 492 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 493 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 494 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 495 | golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 496 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 497 | golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 498 | golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 499 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 500 | golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 501 | golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 502 | golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 503 | golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 504 | golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 505 | golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 506 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 507 | golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 508 | golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 509 | golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 510 | golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 511 | golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 512 | golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 513 | golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 514 | golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= 515 | golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 516 | golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 517 | golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 518 | golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 519 | golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 520 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 521 | golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 522 | golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= 523 | golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 524 | golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 525 | golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 526 | golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 527 | golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= 528 | golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 529 | golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 530 | golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 531 | golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs= 532 | golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 533 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 534 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 535 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 536 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 537 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 538 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 539 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 540 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 541 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 542 | google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 543 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 544 | google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 545 | google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 546 | google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 547 | google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 548 | google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 549 | google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 550 | google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 551 | google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 552 | google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 553 | google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= 554 | google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= 555 | google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= 556 | google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= 557 | google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= 558 | google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= 559 | google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= 560 | google.golang.org/api v0.46.0/go.mod h1:ceL4oozhkAiTID8XMmJBsIxID/9wMXJVVFXPg4ylg3I= 561 | google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= 562 | google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= 563 | google.golang.org/api v0.49.0/go.mod h1:BECiH72wsfwUvOVn3+btPD5WHi0LzavZReBndi42L18= 564 | google.golang.org/api v0.50.0 h1:LX7NFCFYOHzr7WHaYiRUpeipZe9o5L8T+2F4Z798VDw= 565 | google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= 566 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 567 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 568 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 569 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 570 | google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 571 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 572 | google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 573 | google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= 574 | google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 575 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 576 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 577 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 578 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 579 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 580 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 581 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 582 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 583 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 584 | google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 585 | google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 586 | google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 587 | google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 588 | google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 589 | google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= 590 | google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 591 | google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 592 | google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 593 | google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 594 | google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 595 | google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 596 | google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 597 | google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 598 | google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 599 | google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= 600 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 601 | google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= 602 | google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 603 | google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 604 | google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 605 | google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 606 | google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 607 | google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 608 | google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 609 | google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 610 | google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 611 | google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 612 | google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 613 | google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 614 | google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= 615 | google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= 616 | google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= 617 | google.golang.org/genproto v0.0.0-20210517163617-5e0236093d7a/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= 618 | google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= 619 | google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= 620 | google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= 621 | google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= 622 | google.golang.org/genproto v0.0.0-20210624174822-c5cf32407d0a/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= 623 | google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= 624 | google.golang.org/genproto v0.0.0-20210701133433-6b8dcf568a95/go.mod h1:yiaVoXHpRzHGyxV3o4DktVWY4mSUErTKaeEOq6C3t3U= 625 | google.golang.org/genproto v0.0.0-20210708141623-e76da96a951f h1:khwpF3oSk7GIab/7DDMDyE8cPQEO6FAfOcWHIRAhO20= 626 | google.golang.org/genproto v0.0.0-20210708141623-e76da96a951f/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= 627 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 628 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 629 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 630 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 631 | google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 632 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 633 | google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 634 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 635 | google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 636 | google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= 637 | google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= 638 | google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 639 | google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 640 | google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 641 | google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= 642 | google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= 643 | google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= 644 | google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 645 | google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 646 | google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 647 | google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= 648 | google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= 649 | google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= 650 | google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI= 651 | google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= 652 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= 653 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 654 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 655 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 656 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 657 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 658 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 659 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 660 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 661 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 662 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 663 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 664 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 665 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 666 | google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= 667 | google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 668 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 669 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 670 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 671 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 672 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 673 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 674 | gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= 675 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 676 | gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= 677 | gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 678 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 679 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 680 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 681 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 682 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 683 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 684 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 685 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 686 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 687 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 688 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 689 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 690 | honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 691 | honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= 692 | honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 693 | rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= 694 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 695 | rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY= 696 | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= 697 | rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= 698 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 699 | -------------------------------------------------------------------------------- /goblet-server/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/google/goblet/goblet-server", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//:go_default_library", 10 | "//google:go_default_library", 11 | "@com_github_google_uuid//:go_default_library", 12 | "@com_google_cloud_go//errorreporting:go_default_library", 13 | "@com_google_cloud_go_logging//:go_default_library", 14 | "@com_google_cloud_go_storage//:go_default_library", 15 | "@go_googleapis//google/logging/v2:logging_go_proto", 16 | "@io_opencensus_go//stats/view:go_default_library", 17 | "@io_opencensus_go//tag:go_default_library", 18 | "@io_opencensus_go_contrib_exporter_stackdriver//:go_default_library", 19 | "@org_golang_x_oauth2//google:go_default_library", 20 | ], 21 | ) 22 | 23 | go_binary( 24 | name = "goblet-server", 25 | embed = [":go_default_library"], 26 | visibility = ["//visibility:public"], 27 | ) 28 | -------------------------------------------------------------------------------- /goblet-server/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "context" 19 | "flag" 20 | "fmt" 21 | "io" 22 | "log" 23 | "net/http" 24 | "net/http/httputil" 25 | "net/url" 26 | "os" 27 | "time" 28 | 29 | "cloud.google.com/go/errorreporting" 30 | "cloud.google.com/go/logging" 31 | "cloud.google.com/go/storage" 32 | "contrib.go.opencensus.io/exporter/stackdriver" 33 | "github.com/google/goblet" 34 | googlehook "github.com/google/goblet/google" 35 | "github.com/google/uuid" 36 | "go.opencensus.io/stats/view" 37 | "go.opencensus.io/tag" 38 | "golang.org/x/oauth2/google" 39 | 40 | logpb "google.golang.org/genproto/googleapis/logging/v2" 41 | ) 42 | 43 | const ( 44 | scopeCloudPlatform = "https://www.googleapis.com/auth/cloud-platform" 45 | scopeUserInfoEmail = "https://www.googleapis.com/auth/userinfo.email" 46 | ) 47 | 48 | var ( 49 | port = flag.Int("port", 8080, "port to listen to") 50 | cacheRoot = flag.String("cache_root", "", "Root directory of cached repositories") 51 | 52 | stackdriverProject = flag.String("stackdriver_project", "", "GCP project ID used for the Stackdriver integration") 53 | stackdriverLoggingLogID = flag.String("stackdriver_logging_log_id", "", "Stackdriver logging Log ID") 54 | 55 | backupBucketName = flag.String("backup_bucket_name", "", "Name of the GCS bucket for backed-up repositories") 56 | backupManifestName = flag.String("backup_manifest_name", "", "Name of the backup manifest") 57 | 58 | latencyDistributionAggregation = view.Distribution( 59 | 100, 60 | 200, 61 | 400, 62 | 800, 63 | 1000, // 1s 64 | 2000, 65 | 4000, 66 | 8000, 67 | 10000, // 10s 68 | 20000, 69 | 40000, 70 | 80000, 71 | 100000, // 100s 72 | 200000, 73 | 400000, 74 | 800000, 75 | 1000000, // 1000s 76 | 2000000, 77 | 4000000, 78 | 8000000, 79 | ) 80 | views = []*view.View{ 81 | { 82 | Name: "github.com/google/goblet/inbound-command-count", 83 | Description: "Inbound command count", 84 | TagKeys: []tag.Key{goblet.CommandTypeKey, goblet.CommandCanonicalStatusKey, goblet.CommandCacheStateKey}, 85 | Measure: goblet.InboundCommandCount, 86 | Aggregation: view.Count(), 87 | }, 88 | { 89 | Name: "github.com/google/goblet/inbound-command-latency", 90 | Description: "Inbound command latency", 91 | TagKeys: []tag.Key{goblet.CommandTypeKey, goblet.CommandCanonicalStatusKey, goblet.CommandCacheStateKey}, 92 | Measure: goblet.InboundCommandProcessingTime, 93 | Aggregation: latencyDistributionAggregation, 94 | }, 95 | { 96 | Name: "github.com/google/goblet/outbound-command-count", 97 | Description: "Outbound command count", 98 | TagKeys: []tag.Key{goblet.CommandTypeKey, goblet.CommandCanonicalStatusKey}, 99 | Measure: goblet.OutboundCommandCount, 100 | Aggregation: view.Count(), 101 | }, 102 | { 103 | Name: "github.com/google/goblet/outbound-command-latency", 104 | Description: "Outbound command latency", 105 | TagKeys: []tag.Key{goblet.CommandTypeKey, goblet.CommandCanonicalStatusKey}, 106 | Measure: goblet.OutboundCommandProcessingTime, 107 | Aggregation: latencyDistributionAggregation, 108 | }, 109 | { 110 | Name: "github.com/google/goblet/upstream-fetch-blocking-time", 111 | Description: "Duration that requests are waiting for git-fetch from the upstream", 112 | Measure: goblet.UpstreamFetchWaitingTime, 113 | Aggregation: latencyDistributionAggregation, 114 | }, 115 | } 116 | ) 117 | 118 | func main() { 119 | flag.Parse() 120 | 121 | ts, err := google.DefaultTokenSource(context.Background(), scopeCloudPlatform, scopeUserInfoEmail) 122 | if err != nil { 123 | log.Fatalf("Cannot initialize the OAuth2 token source: %v", err) 124 | } 125 | authorizer, err := googlehook.NewRequestAuthorizer(ts) 126 | if err != nil { 127 | log.Fatalf("Cannot create a request authorizer: %v", err) 128 | } 129 | if err := view.Register(views...); err != nil { 130 | log.Fatal(err) 131 | } 132 | 133 | var er func(*http.Request, error) 134 | var rl func(r *http.Request, status int, requestSize, responseSize int64, latency time.Duration) = func(r *http.Request, status int, requestSize, responseSize int64, latency time.Duration) { 135 | dump, err := httputil.DumpRequest(r, false) 136 | if err != nil { 137 | return 138 | } 139 | log.Printf("%q %d reqsize: %d, respsize %d, latency: %v", dump, status, requestSize, responseSize, latency) 140 | } 141 | var lrol func(string, *url.URL) goblet.RunningOperation = func(action string, u *url.URL) goblet.RunningOperation { 142 | log.Printf("Starting %s for %s", action, u.String()) 143 | return &logBasedOperation{action, u} 144 | } 145 | var backupLogger *log.Logger = log.New(os.Stderr, "", log.LstdFlags) 146 | if *stackdriverProject != "" { 147 | // Error reporter 148 | ec, err := errorreporting.NewClient(context.Background(), *stackdriverProject, errorreporting.Config{ 149 | ServiceName: "goblet", 150 | }) 151 | if err != nil { 152 | log.Fatalf("Cannot create a Stackdriver errorreporting client: %v", err) 153 | } 154 | defer func() { 155 | if err := ec.Close(); err != nil { 156 | log.Printf("Failed to report errors to Stackdriver: %v", err) 157 | } 158 | }() 159 | er = func(r *http.Request, err error) { 160 | ec.Report(errorreporting.Entry{ 161 | Req: r, 162 | Error: err, 163 | }) 164 | log.Printf("Error while processing a request: %v", err) 165 | } 166 | 167 | if *stackdriverLoggingLogID != "" { 168 | lc, err := logging.NewClient(context.Background(), *stackdriverProject) 169 | if err != nil { 170 | log.Fatalf("Cannot create a Stackdriver logging client: %v", err) 171 | } 172 | defer func() { 173 | if err := lc.Close(); err != nil { 174 | log.Printf("Failed to log requests to Stackdriver: %v", err) 175 | } 176 | }() 177 | 178 | // Request logger 179 | sdLogger := lc.Logger(*stackdriverLoggingLogID) 180 | rl = func(r *http.Request, status int, requestSize, responseSize int64, latency time.Duration) { 181 | sdLogger.Log(logging.Entry{ 182 | HTTPRequest: &logging.HTTPRequest{ 183 | Request: r, 184 | RequestSize: requestSize, 185 | Status: status, 186 | ResponseSize: responseSize, 187 | Latency: latency, 188 | RemoteIP: r.RemoteAddr, 189 | }, 190 | }) 191 | } 192 | lrol = func(action string, u *url.URL) goblet.RunningOperation { 193 | op := &stackdriverBasedOperation{ 194 | sdLogger: sdLogger, 195 | action: action, 196 | u: u, 197 | startTime: time.Now(), 198 | id: uuid.New().String(), 199 | } 200 | op.sdLogger.Log(logging.Entry{ 201 | Payload: &LongRunningOperation{ 202 | Action: op.action, 203 | URL: op.u.String(), 204 | }, 205 | Operation: &logpb.LogEntryOperation{ 206 | Id: op.id, 207 | Producer: "github.com/google/goblet", 208 | First: true, 209 | }, 210 | }) 211 | return op 212 | } 213 | // Backup logger 214 | backupLogger = sdLogger.StandardLogger(logging.Warning) 215 | } 216 | 217 | // OpenCensus view exporters. 218 | exporter, err := stackdriver.NewExporter(stackdriver.Options{ 219 | ProjectID: *stackdriverProject, 220 | }) 221 | if err != nil { 222 | log.Fatal(err) 223 | } 224 | if err = exporter.StartMetricsExporter(); err != nil { 225 | log.Fatal(err) 226 | } 227 | } 228 | 229 | config := &goblet.ServerConfig{ 230 | LocalDiskCacheRoot: *cacheRoot, 231 | URLCanonializer: googlehook.CanonicalizeURL, 232 | RequestAuthorizer: authorizer, 233 | TokenSource: ts, 234 | ErrorReporter: er, 235 | RequestLogger: rl, 236 | LongRunningOperationLogger: lrol, 237 | } 238 | 239 | if *backupBucketName != "" && *backupManifestName != "" { 240 | gsClient, err := storage.NewClient(context.Background()) 241 | if err != nil { 242 | log.Fatal(err) 243 | } 244 | 245 | googlehook.RunBackupProcess(config, gsClient.Bucket(*backupBucketName), *backupManifestName, backupLogger) 246 | } 247 | 248 | http.HandleFunc("/healthz", func(w http.ResponseWriter, req *http.Request) { 249 | w.Header().Set("Content-Type", "text/plain") 250 | io.WriteString(w, "ok\n") 251 | }) 252 | http.Handle("/", goblet.HTTPHandler(config)) 253 | log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) 254 | } 255 | 256 | type LongRunningOperation struct { 257 | Action string `json:"action"` 258 | URL string `json:"url"` 259 | DurationMs int `json:"duration_msec,omitempty"` 260 | Error string `json:"error,omitempty"` 261 | ProgressMessage string `json:"progress_message,omitempty"` 262 | } 263 | 264 | type logBasedOperation struct { 265 | action string 266 | u *url.URL 267 | } 268 | 269 | func (op *logBasedOperation) Printf(format string, a ...interface{}) { 270 | log.Printf("Progress %s (%s): %s", op.action, op.u.String(), fmt.Sprintf(format, a...)) 271 | } 272 | 273 | func (op *logBasedOperation) Done(err error) { 274 | log.Printf("Finished %s for %s: %v", op.action, op.u.String(), err) 275 | } 276 | 277 | type stackdriverBasedOperation struct { 278 | sdLogger *logging.Logger 279 | action string 280 | u *url.URL 281 | startTime time.Time 282 | id string 283 | } 284 | 285 | func (op *stackdriverBasedOperation) Printf(format string, a ...interface{}) { 286 | lro := &LongRunningOperation{ 287 | Action: op.action, 288 | URL: op.u.String(), 289 | ProgressMessage: fmt.Sprintf(format, a...), 290 | } 291 | op.sdLogger.Log(logging.Entry{ 292 | Payload: lro, 293 | Operation: &logpb.LogEntryOperation{ 294 | Id: op.id, 295 | Producer: "github.com/google/goblet", 296 | }, 297 | }) 298 | } 299 | 300 | func (op *stackdriverBasedOperation) Done(err error) { 301 | lro := &LongRunningOperation{ 302 | Action: op.action, 303 | URL: op.u.String(), 304 | DurationMs: int(time.Since(op.startTime) / time.Millisecond), 305 | } 306 | if err != nil { 307 | lro.Error = err.Error() 308 | } 309 | op.sdLogger.Log(logging.Entry{ 310 | Payload: lro, 311 | Operation: &logpb.LogEntryOperation{ 312 | Id: op.id, 313 | Producer: "github.com/google/goblet", 314 | Last: true, 315 | }, 316 | }) 317 | } 318 | -------------------------------------------------------------------------------- /goblet.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "io" 19 | "net/http" 20 | "net/url" 21 | "time" 22 | 23 | "go.opencensus.io/stats" 24 | "go.opencensus.io/tag" 25 | "golang.org/x/oauth2" 26 | ) 27 | 28 | var ( 29 | // CommandTypeKey indicates a command type ("ls-refs", "fetch", 30 | // "not-a-command"). 31 | CommandTypeKey = tag.MustNewKey("github.com/google/goblet/command-type") 32 | 33 | // CommandCacheStateKey indicates whether the command response is cached 34 | // or not ("locally-served", "queried-upstream"). 35 | CommandCacheStateKey = tag.MustNewKey("github.com/google/goblet/command-cache-state") 36 | 37 | // CommandCanonicalStatusKey indicates whether the command is succeeded 38 | // or not ("OK", "Unauthenticated"). 39 | CommandCanonicalStatusKey = tag.MustNewKey("github.com/google/goblet/command-status") 40 | 41 | // InboundCommandProcessingTime is a processing time of the inbound 42 | // commands. 43 | InboundCommandProcessingTime = stats.Int64("github.com/google/goblet/inbound-command-processing-time", "processing time of inbound commands", stats.UnitMilliseconds) 44 | 45 | // OutboundCommandProcessingTime is a processing time of the outbound 46 | // commands. 47 | OutboundCommandProcessingTime = stats.Int64("github.com/google/goblet/outbound-command-processing-time", "processing time of outbound commands", stats.UnitMilliseconds) 48 | 49 | // UpstreamFetchWaitingTime is a duration that a fetch request waited 50 | // for the upstream. 51 | UpstreamFetchWaitingTime = stats.Int64("github.com/google/goblet/upstream-fetch-waiting-time", "waiting time of upstream fetch command", stats.UnitMilliseconds) 52 | 53 | // InboundCommandCount is a count of inbound commands. 54 | InboundCommandCount = stats.Int64("github.com/google/goblet/inbound-command-count", "number of inbound commands", stats.UnitDimensionless) 55 | 56 | // OutboundCommandCount is a count of outbound commands. 57 | OutboundCommandCount = stats.Int64("github.com/google/goblet/outbound-command-count", "number of outbound commands", stats.UnitDimensionless) 58 | ) 59 | 60 | type ServerConfig struct { 61 | LocalDiskCacheRoot string 62 | 63 | URLCanonializer func(*url.URL) (*url.URL, error) 64 | 65 | RequestAuthorizer func(*http.Request) error 66 | 67 | TokenSource oauth2.TokenSource 68 | 69 | ErrorReporter func(*http.Request, error) 70 | 71 | RequestLogger func(r *http.Request, status int, requestSize, responseSize int64, latency time.Duration) 72 | 73 | LongRunningOperationLogger func(string, *url.URL) RunningOperation 74 | } 75 | 76 | type RunningOperation interface { 77 | Printf(format string, a ...interface{}) 78 | 79 | Done(error) 80 | } 81 | 82 | type ManagedRepository interface { 83 | UpstreamURL() *url.URL 84 | 85 | LastUpdateTime() time.Time 86 | 87 | RecoverFromBundle(string) error 88 | 89 | WriteBundle(io.Writer) error 90 | } 91 | 92 | func HTTPHandler(config *ServerConfig) http.Handler { 93 | return &httpProxyServer{config} 94 | } 95 | 96 | func OpenManagedRepository(config *ServerConfig, u *url.URL) (ManagedRepository, error) { 97 | return openManagedRepository(config, u) 98 | } 99 | 100 | func ListManagedRepositories(fn func(ManagedRepository)) { 101 | managedRepos.Range(func(key, value interface{}) bool { 102 | m := value.(*managedRepository) 103 | fn(m) 104 | return true 105 | }) 106 | } 107 | -------------------------------------------------------------------------------- /goblet_deps.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_gazelle//:deps.bzl", "go_repository") 2 | 3 | def goblet_deps(): 4 | go_repository( 5 | name = "co_honnef_go_tools", 6 | importpath = "honnef.co/go/tools", 7 | sum = "h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=", 8 | version = "v0.0.1-2020.1.4", 9 | ) 10 | go_repository( 11 | name = "com_github_acomagu_bufpipe", 12 | importpath = "github.com/acomagu/bufpipe", 13 | sum = "h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=", 14 | version = "v1.0.3", 15 | ) 16 | go_repository( 17 | name = "com_github_anmitsu_go_shlex", 18 | importpath = "github.com/anmitsu/go-shlex", 19 | sum = "h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=", 20 | version = "v0.0.0-20161002113705-648efa622239", 21 | ) 22 | go_repository( 23 | name = "com_github_antihax_optional", 24 | importpath = "github.com/antihax/optional", 25 | sum = "h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=", 26 | version = "v1.0.0", 27 | ) 28 | go_repository( 29 | name = "com_github_armon_go_socks5", 30 | importpath = "github.com/armon/go-socks5", 31 | sum = "h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=", 32 | version = "v0.0.0-20160902184237-e75332964ef5", 33 | ) 34 | go_repository( 35 | name = "com_github_aws_aws_sdk_go", 36 | importpath = "github.com/aws/aws-sdk-go", 37 | sum = "h1:IaXfqtioP6p9SFAnNfsqdNczbR5UNbYqvcZUSsCAdTY=", 38 | version = "v1.30.7", 39 | ) 40 | go_repository( 41 | name = "com_github_burntsushi_toml", 42 | importpath = "github.com/BurntSushi/toml", 43 | sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", 44 | version = "v0.3.1", 45 | ) 46 | go_repository( 47 | name = "com_github_burntsushi_xgb", 48 | importpath = "github.com/BurntSushi/xgb", 49 | sum = "h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=", 50 | version = "v0.0.0-20160522181843-27f122750802", 51 | ) 52 | go_repository( 53 | name = "com_github_census_instrumentation_opencensus_proto", 54 | build_directives = [ 55 | "gazelle:resolve go github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1 //gen-go/agent/common/v1:go_default_library", 56 | "gazelle:resolve go github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1 //gen-go/metrics/v1:go_default_library", 57 | "gazelle:resolve go github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1 //gen-go/resource/v1:go_default_library", 58 | "gazelle:resolve go github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 //gen-go/trace/v1:go_default_library", 59 | ], 60 | importpath = "github.com/census-instrumentation/opencensus-proto", 61 | sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=", 62 | version = "v0.2.1", 63 | ) 64 | go_repository( 65 | name = "com_github_chzyer_logex", 66 | importpath = "github.com/chzyer/logex", 67 | sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=", 68 | version = "v1.1.10", 69 | ) 70 | go_repository( 71 | name = "com_github_chzyer_readline", 72 | importpath = "github.com/chzyer/readline", 73 | sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=", 74 | version = "v0.0.0-20180603132655-2972be24d48e", 75 | ) 76 | go_repository( 77 | name = "com_github_chzyer_test", 78 | importpath = "github.com/chzyer/test", 79 | sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=", 80 | version = "v0.0.0-20180213035817-a1ea475d72b1", 81 | ) 82 | go_repository( 83 | name = "com_github_client9_misspell", 84 | importpath = "github.com/client9/misspell", 85 | sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", 86 | version = "v0.3.4", 87 | ) 88 | go_repository( 89 | name = "com_github_cncf_udpa_go", 90 | importpath = "github.com/cncf/udpa/go", 91 | sum = "h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=", 92 | version = "v0.0.0-20201120205902-5459f2c99403", 93 | ) 94 | go_repository( 95 | name = "com_github_cncf_xds_go", 96 | importpath = "github.com/cncf/xds/go", 97 | sum = "h1:OZmjad4L3H8ncOIR8rnb5MREYqG8ixi5+WbeUsquF0c=", 98 | version = "v0.0.0-20210312221358-fbca930ec8ed", 99 | ) 100 | go_repository( 101 | name = "com_github_creack_pty", 102 | importpath = "github.com/creack/pty", 103 | sum = "h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=", 104 | version = "v1.1.9", 105 | ) 106 | go_repository( 107 | name = "com_github_davecgh_go_spew", 108 | importpath = "github.com/davecgh/go-spew", 109 | sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", 110 | version = "v1.1.1", 111 | ) 112 | go_repository( 113 | name = "com_github_emirpasic_gods", 114 | importpath = "github.com/emirpasic/gods", 115 | sum = "h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=", 116 | version = "v1.12.0", 117 | ) 118 | go_repository( 119 | name = "com_github_envoyproxy_go_control_plane", 120 | importpath = "github.com/envoyproxy/go-control-plane", 121 | sum = "h1:dulLQAYQFYtG5MTplgNGHWuV2D+OBD+Z8lmDBmbLg+s=", 122 | version = "v0.9.9-0.20210512163311-63b5d3c536b0", 123 | ) 124 | go_repository( 125 | name = "com_github_envoyproxy_protoc_gen_validate", 126 | importpath = "github.com/envoyproxy/protoc-gen-validate", 127 | sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", 128 | version = "v0.1.0", 129 | ) 130 | go_repository( 131 | name = "com_github_flynn_go_shlex", 132 | importpath = "github.com/flynn/go-shlex", 133 | sum = "h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=", 134 | version = "v0.0.0-20150515145356-3f9db97f8568", 135 | ) 136 | go_repository( 137 | name = "com_github_ghodss_yaml", 138 | importpath = "github.com/ghodss/yaml", 139 | sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=", 140 | version = "v1.0.0", 141 | ) 142 | go_repository( 143 | name = "com_github_gliderlabs_ssh", 144 | importpath = "github.com/gliderlabs/ssh", 145 | sum = "h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=", 146 | version = "v0.2.2", 147 | ) 148 | go_repository( 149 | name = "com_github_go_git_gcfg", 150 | importpath = "github.com/go-git/gcfg", 151 | sum = "h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=", 152 | version = "v1.5.0", 153 | ) 154 | go_repository( 155 | name = "com_github_go_git_go_billy_v5", 156 | importpath = "github.com/go-git/go-billy/v5", 157 | sum = "h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34=", 158 | version = "v5.3.1", 159 | ) 160 | go_repository( 161 | name = "com_github_go_git_go_git_fixtures_v4", 162 | importpath = "github.com/go-git/go-git-fixtures/v4", 163 | sum = "h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=", 164 | version = "v4.2.1", 165 | ) 166 | go_repository( 167 | name = "com_github_go_git_go_git_v5", 168 | importpath = "github.com/go-git/go-git/v5", 169 | sum = "h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=", 170 | version = "v5.4.2", 171 | ) 172 | go_repository( 173 | name = "com_github_go_gl_glfw", 174 | importpath = "github.com/go-gl/glfw", 175 | sum = "h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=", 176 | version = "v0.0.0-20190409004039-e6da0acd62b1", 177 | ) 178 | go_repository( 179 | name = "com_github_go_gl_glfw_v3_3_glfw", 180 | importpath = "github.com/go-gl/glfw/v3.3/glfw", 181 | sum = "h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=", 182 | version = "v0.0.0-20200222043503-6f7a984d4dc4", 183 | ) 184 | go_repository( 185 | name = "com_github_go_sql_driver_mysql", 186 | importpath = "github.com/go-sql-driver/mysql", 187 | sum = "h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=", 188 | version = "v1.5.0", 189 | ) 190 | go_repository( 191 | name = "com_github_golang_glog", 192 | importpath = "github.com/golang/glog", 193 | sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=", 194 | version = "v0.0.0-20160126235308-23def4e6c14b", 195 | ) 196 | go_repository( 197 | name = "com_github_golang_groupcache", 198 | importpath = "github.com/golang/groupcache", 199 | sum = "h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=", 200 | version = "v0.0.0-20210331224755-41bb18bfe9da", 201 | ) 202 | go_repository( 203 | name = "com_github_golang_mock", 204 | importpath = "github.com/golang/mock", 205 | sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", 206 | version = "v1.6.0", 207 | ) 208 | go_repository( 209 | name = "com_github_golang_protobuf", 210 | importpath = "github.com/golang/protobuf", 211 | sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", 212 | version = "v1.5.2", 213 | ) 214 | go_repository( 215 | name = "com_github_golang_snappy", 216 | importpath = "github.com/golang/snappy", 217 | sum = "h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=", 218 | version = "v0.0.3", 219 | ) 220 | 221 | go_repository( 222 | name = "com_github_google_btree", 223 | importpath = "github.com/google/btree", 224 | sum = "h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=", 225 | version = "v1.0.0", 226 | ) 227 | go_repository( 228 | name = "com_github_google_gitprotocolio", 229 | importpath = "github.com/google/gitprotocolio", 230 | sum = "h1:/a887PZoXM9aLYwXS2ufq+Gnr5KUg5gm8gBoxKjnQuo=", 231 | version = "v0.0.0-20210704173409-b5a56823ae52", 232 | ) 233 | go_repository( 234 | name = "com_github_google_go_cmp", 235 | importpath = "github.com/google/go-cmp", 236 | sum = "h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=", 237 | version = "v0.5.6", 238 | ) 239 | go_repository( 240 | name = "com_github_google_martian", 241 | importpath = "github.com/google/martian", 242 | sum = "h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=", 243 | version = "v2.1.0+incompatible", 244 | ) 245 | go_repository( 246 | name = "com_github_google_martian_v3", 247 | importpath = "github.com/google/martian/v3", 248 | sum = "h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ=", 249 | version = "v3.2.1", 250 | ) 251 | go_repository( 252 | name = "com_github_google_pprof", 253 | importpath = "github.com/google/pprof", 254 | sum = "h1:2tft2559dNwKl2znYB58oVTql0grRB+Ml3LWIBbc4WM=", 255 | version = "v0.0.0-20210609004039-a478d1d731e9", 256 | ) 257 | go_repository( 258 | name = "com_github_google_renameio", 259 | importpath = "github.com/google/renameio", 260 | sum = "h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=", 261 | version = "v0.1.0", 262 | ) 263 | go_repository( 264 | name = "com_github_google_uuid", 265 | importpath = "github.com/google/uuid", 266 | sum = "h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=", 267 | version = "v1.1.2", 268 | ) 269 | go_repository( 270 | name = "com_github_googleapis_gax_go_v2", 271 | importpath = "github.com/googleapis/gax-go/v2", 272 | sum = "h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=", 273 | version = "v2.0.5", 274 | ) 275 | go_repository( 276 | name = "com_github_grpc_ecosystem_grpc_gateway", 277 | importpath = "github.com/grpc-ecosystem/grpc-gateway", 278 | sum = "h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=", 279 | version = "v1.16.0", 280 | ) 281 | go_repository( 282 | name = "com_github_hashicorp_golang_lru", 283 | importpath = "github.com/hashicorp/golang-lru", 284 | sum = "h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=", 285 | version = "v0.5.1", 286 | ) 287 | go_repository( 288 | name = "com_github_ianlancetaylor_demangle", 289 | importpath = "github.com/ianlancetaylor/demangle", 290 | sum = "h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=", 291 | version = "v0.0.0-20200824232613-28f6c0f3b639", 292 | ) 293 | go_repository( 294 | name = "com_github_imdario_mergo", 295 | importpath = "github.com/imdario/mergo", 296 | sum = "h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=", 297 | version = "v0.3.12", 298 | ) 299 | go_repository( 300 | name = "com_github_jbenet_go_context", 301 | importpath = "github.com/jbenet/go-context", 302 | sum = "h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=", 303 | version = "v0.0.0-20150711004518-d14ea06fba99", 304 | ) 305 | go_repository( 306 | name = "com_github_jessevdk_go_flags", 307 | importpath = "github.com/jessevdk/go-flags", 308 | sum = "h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=", 309 | version = "v1.5.0", 310 | ) 311 | go_repository( 312 | name = "com_github_jmespath_go_jmespath", 313 | importpath = "github.com/jmespath/go-jmespath", 314 | sum = "h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=", 315 | version = "v0.3.0", 316 | ) 317 | go_repository( 318 | name = "com_github_jstemmer_go_junit_report", 319 | importpath = "github.com/jstemmer/go-junit-report", 320 | sum = "h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=", 321 | version = "v0.9.1", 322 | ) 323 | go_repository( 324 | name = "com_github_kevinburke_ssh_config", 325 | importpath = "github.com/kevinburke/ssh_config", 326 | sum = "h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o=", 327 | version = "v1.1.0", 328 | ) 329 | go_repository( 330 | name = "com_github_kisielk_gotool", 331 | importpath = "github.com/kisielk/gotool", 332 | sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=", 333 | version = "v1.0.0", 334 | ) 335 | go_repository( 336 | name = "com_github_konsorten_go_windows_terminal_sequences", 337 | importpath = "github.com/konsorten/go-windows-terminal-sequences", 338 | sum = "h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=", 339 | version = "v1.0.1", 340 | ) 341 | go_repository( 342 | name = "com_github_kr_pretty", 343 | importpath = "github.com/kr/pretty", 344 | sum = "h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=", 345 | version = "v0.2.1", 346 | ) 347 | go_repository( 348 | name = "com_github_kr_pty", 349 | importpath = "github.com/kr/pty", 350 | sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=", 351 | version = "v1.1.1", 352 | ) 353 | go_repository( 354 | name = "com_github_kr_text", 355 | importpath = "github.com/kr/text", 356 | sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=", 357 | version = "v0.2.0", 358 | ) 359 | go_repository( 360 | name = "com_github_matryer_is", 361 | importpath = "github.com/matryer/is", 362 | sum = "h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=", 363 | version = "v1.2.0", 364 | ) 365 | go_repository( 366 | name = "com_github_microsoft_go_winio", 367 | importpath = "github.com/Microsoft/go-winio", 368 | sum = "h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=", 369 | version = "v0.5.0", 370 | ) 371 | go_repository( 372 | name = "com_github_mitchellh_go_homedir", 373 | importpath = "github.com/mitchellh/go-homedir", 374 | sum = "h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=", 375 | version = "v1.1.0", 376 | ) 377 | go_repository( 378 | name = "com_github_niemeyer_pretty", 379 | importpath = "github.com/niemeyer/pretty", 380 | sum = "h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=", 381 | version = "v0.0.0-20200227124842-a10e7caefd8e", 382 | ) 383 | go_repository( 384 | name = "com_github_pkg_errors", 385 | importpath = "github.com/pkg/errors", 386 | sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", 387 | version = "v0.9.1", 388 | ) 389 | go_repository( 390 | name = "com_github_pmezard_go_difflib", 391 | importpath = "github.com/pmezard/go-difflib", 392 | sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", 393 | version = "v1.0.0", 394 | ) 395 | go_repository( 396 | name = "com_github_prometheus_client_model", 397 | importpath = "github.com/prometheus/client_model", 398 | sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=", 399 | version = "v0.0.0-20190812154241-14fe0d1b01d4", 400 | ) 401 | go_repository( 402 | name = "com_github_protonmail_go_crypto", 403 | importpath = "github.com/ProtonMail/go-crypto", 404 | sum = "h1:BF5p87XWvmgdrTPPzcRMwC0TMQbviwQ+uBKfNfWJy50=", 405 | version = "v0.0.0-20210705153151-cc34b1f6908b", 406 | ) 407 | go_repository( 408 | name = "com_github_rogpeppe_fastuuid", 409 | importpath = "github.com/rogpeppe/fastuuid", 410 | sum = "h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=", 411 | version = "v1.2.0", 412 | ) 413 | go_repository( 414 | name = "com_github_rogpeppe_go_internal", 415 | importpath = "github.com/rogpeppe/go-internal", 416 | sum = "h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=", 417 | version = "v1.3.0", 418 | ) 419 | go_repository( 420 | name = "com_github_sergi_go_diff", 421 | importpath = "github.com/sergi/go-diff", 422 | sum = "h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=", 423 | version = "v1.2.0", 424 | ) 425 | go_repository( 426 | name = "com_github_sirupsen_logrus", 427 | importpath = "github.com/sirupsen/logrus", 428 | sum = "h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=", 429 | version = "v1.7.0", 430 | ) 431 | go_repository( 432 | name = "com_github_stretchr_objx", 433 | importpath = "github.com/stretchr/objx", 434 | sum = "h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=", 435 | version = "v0.1.1", 436 | ) 437 | go_repository( 438 | name = "com_github_stretchr_testify", 439 | importpath = "github.com/stretchr/testify", 440 | sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=", 441 | version = "v1.7.0", 442 | ) 443 | go_repository( 444 | name = "com_github_xanzy_ssh_agent", 445 | importpath = "github.com/xanzy/ssh-agent", 446 | sum = "h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=", 447 | version = "v0.3.0", 448 | ) 449 | go_repository( 450 | name = "com_github_yuin_goldmark", 451 | importpath = "github.com/yuin/goldmark", 452 | sum = "h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=", 453 | version = "v1.3.5", 454 | ) 455 | go_repository( 456 | name = "com_google_cloud_go", 457 | importpath = "cloud.google.com/go", 458 | sum = "h1:Lo1JDRwMOAxQxTQcbGXi4p60jyMoXNpkmzzzL2Agt5k=", 459 | version = "v0.86.0", 460 | ) 461 | go_repository( 462 | name = "com_google_cloud_go_bigquery", 463 | importpath = "cloud.google.com/go/bigquery", 464 | sum = "h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=", 465 | version = "v1.8.0", 466 | ) 467 | go_repository( 468 | name = "com_google_cloud_go_datastore", 469 | importpath = "cloud.google.com/go/datastore", 470 | sum = "h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=", 471 | version = "v1.1.0", 472 | ) 473 | go_repository( 474 | name = "com_google_cloud_go_logging", 475 | importpath = "cloud.google.com/go/logging", 476 | sum = "h1:Mu2Q75VBDQlW1HlBMjTX4X84UFR73G1TiLlRYc/b7tA=", 477 | version = "v1.4.2", 478 | ) 479 | go_repository( 480 | name = "com_google_cloud_go_pubsub", 481 | importpath = "cloud.google.com/go/pubsub", 482 | sum = "h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=", 483 | version = "v1.3.1", 484 | ) 485 | go_repository( 486 | name = "com_google_cloud_go_storage", 487 | importpath = "cloud.google.com/go/storage", 488 | sum = "h1:1UwAux2OZP4310YXg5ohqBEpV16Y93uZG4+qOX7K2Kg=", 489 | version = "v1.16.0", 490 | ) 491 | go_repository( 492 | name = "com_shuralyov_dmitri_gpu_mtl", 493 | importpath = "dmitri.shuralyov.com/gpu/mtl", 494 | sum = "h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=", 495 | version = "v0.0.0-20190408044501-666a987793e9", 496 | ) 497 | go_repository( 498 | name = "in_gopkg_check_v1", 499 | importpath = "gopkg.in/check.v1", 500 | sum = "h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=", 501 | version = "v1.0.0-20201130134442-10cb98267c6c", 502 | ) 503 | go_repository( 504 | name = "in_gopkg_errgo_v2", 505 | importpath = "gopkg.in/errgo.v2", 506 | sum = "h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=", 507 | version = "v2.1.0", 508 | ) 509 | go_repository( 510 | name = "in_gopkg_warnings_v0", 511 | importpath = "gopkg.in/warnings.v0", 512 | sum = "h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=", 513 | version = "v0.1.2", 514 | ) 515 | go_repository( 516 | name = "in_gopkg_yaml_v2", 517 | importpath = "gopkg.in/yaml.v2", 518 | sum = "h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=", 519 | version = "v2.3.0", 520 | ) 521 | go_repository( 522 | name = "in_gopkg_yaml_v3", 523 | importpath = "gopkg.in/yaml.v3", 524 | sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=", 525 | version = "v3.0.0-20200313102051-9f266ea9e77c", 526 | ) 527 | go_repository( 528 | name = "io_opencensus_go", 529 | importpath = "go.opencensus.io", 530 | sum = "h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=", 531 | version = "v0.23.0", 532 | ) 533 | go_repository( 534 | name = "io_opencensus_go_contrib_exporter_stackdriver", 535 | importpath = "contrib.go.opencensus.io/exporter/stackdriver", 536 | sum = "h1:RX9W6FelAqTVnBi/bRXJLXr9n18v4QkQwZYIdnNS51I=", 537 | version = "v0.13.1", 538 | ) 539 | go_repository( 540 | name = "io_opentelemetry_go_proto_otlp", 541 | importpath = "go.opentelemetry.io/proto/otlp", 542 | sum = "h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=", 543 | version = "v0.7.0", 544 | ) 545 | go_repository( 546 | name = "io_rsc_binaryregexp", 547 | importpath = "rsc.io/binaryregexp", 548 | sum = "h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=", 549 | version = "v0.2.0", 550 | ) 551 | go_repository( 552 | name = "io_rsc_quote_v3", 553 | importpath = "rsc.io/quote/v3", 554 | sum = "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=", 555 | version = "v3.1.0", 556 | ) 557 | go_repository( 558 | name = "io_rsc_sampler", 559 | importpath = "rsc.io/sampler", 560 | sum = "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=", 561 | version = "v1.3.0", 562 | ) 563 | go_repository( 564 | name = "org_golang_google_api", 565 | importpath = "google.golang.org/api", 566 | sum = "h1:LX7NFCFYOHzr7WHaYiRUpeipZe9o5L8T+2F4Z798VDw=", 567 | version = "v0.50.0", 568 | ) 569 | go_repository( 570 | name = "org_golang_google_appengine", 571 | importpath = "google.golang.org/appengine", 572 | sum = "h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=", 573 | version = "v1.6.7", 574 | ) 575 | go_repository( 576 | name = "org_golang_google_genproto", 577 | importpath = "google.golang.org/genproto", 578 | sum = "h1:khwpF3oSk7GIab/7DDMDyE8cPQEO6FAfOcWHIRAhO20=", 579 | version = "v0.0.0-20210708141623-e76da96a951f", 580 | ) 581 | go_repository( 582 | name = "org_golang_google_grpc", 583 | importpath = "google.golang.org/grpc", 584 | sum = "h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI=", 585 | version = "v1.39.0", 586 | ) 587 | go_repository( 588 | name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", 589 | importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", 590 | sum = "h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=", 591 | version = "v1.1.0", 592 | ) 593 | 594 | go_repository( 595 | name = "org_golang_google_protobuf", 596 | importpath = "google.golang.org/protobuf", 597 | sum = "h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=", 598 | version = "v1.27.1", 599 | ) 600 | go_repository( 601 | name = "org_golang_x_crypto", 602 | importpath = "golang.org/x/crypto", 603 | sum = "h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=", 604 | version = "v0.0.0-20210616213533-5ff15b29337e", 605 | ) 606 | go_repository( 607 | name = "org_golang_x_exp", 608 | importpath = "golang.org/x/exp", 609 | sum = "h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=", 610 | version = "v0.0.0-20200224162631-6cc2880d07d6", 611 | ) 612 | go_repository( 613 | name = "org_golang_x_image", 614 | importpath = "golang.org/x/image", 615 | sum = "h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=", 616 | version = "v0.0.0-20190802002840-cff245a6509b", 617 | ) 618 | go_repository( 619 | name = "org_golang_x_lint", 620 | importpath = "golang.org/x/lint", 621 | sum = "h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=", 622 | version = "v0.0.0-20210508222113-6edffad5e616", 623 | ) 624 | go_repository( 625 | name = "org_golang_x_mobile", 626 | importpath = "golang.org/x/mobile", 627 | sum = "h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=", 628 | version = "v0.0.0-20190719004257-d2bd2a29d028", 629 | ) 630 | go_repository( 631 | name = "org_golang_x_mod", 632 | importpath = "golang.org/x/mod", 633 | sum = "h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=", 634 | version = "v0.4.2", 635 | ) 636 | go_repository( 637 | name = "org_golang_x_net", 638 | importpath = "golang.org/x/net", 639 | sum = "h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=", 640 | version = "v0.0.0-20210614182718-04defd469f4e", 641 | ) 642 | go_repository( 643 | name = "org_golang_x_oauth2", 644 | importpath = "golang.org/x/oauth2", 645 | sum = "h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8=", 646 | version = "v0.0.0-20210628180205-a41e5a781914", 647 | ) 648 | go_repository( 649 | name = "org_golang_x_sync", 650 | importpath = "golang.org/x/sync", 651 | sum = "h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=", 652 | version = "v0.0.0-20210220032951-036812b2e83c", 653 | ) 654 | go_repository( 655 | name = "org_golang_x_sys", 656 | importpath = "golang.org/x/sys", 657 | sum = "h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=", 658 | version = "v0.0.0-20210630005230-0f9fa26af87c", 659 | ) 660 | go_repository( 661 | name = "org_golang_x_term", 662 | importpath = "golang.org/x/term", 663 | sum = "h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=", 664 | version = "v0.0.0-20201126162022-7de9c90e9dd1", 665 | ) 666 | go_repository( 667 | name = "org_golang_x_text", 668 | importpath = "golang.org/x/text", 669 | sum = "h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=", 670 | version = "v0.3.6", 671 | ) 672 | go_repository( 673 | name = "org_golang_x_time", 674 | importpath = "golang.org/x/time", 675 | sum = "h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=", 676 | version = "v0.0.0-20191024005414-555d28b269f0", 677 | ) 678 | go_repository( 679 | name = "org_golang_x_tools", 680 | importpath = "golang.org/x/tools", 681 | sum = "h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs=", 682 | version = "v0.1.4", 683 | ) 684 | go_repository( 685 | name = "org_golang_x_xerrors", 686 | importpath = "golang.org/x/xerrors", 687 | sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=", 688 | version = "v0.0.0-20200804184101-5ec99f83aff1", 689 | ) 690 | -------------------------------------------------------------------------------- /google/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "backup.go", 7 | "hooks.go", 8 | ], 9 | importpath = "github.com/google/goblet/google", 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//:go_default_library", 13 | "@com_google_cloud_go_storage//:go_default_library", 14 | "@org_golang_google_api//iterator:go_default_library", 15 | "@org_golang_google_api//oauth2/v2:go_default_library", 16 | "@org_golang_google_api//option:go_default_library", 17 | "@org_golang_google_grpc//codes:go_default_library", 18 | "@org_golang_google_grpc//status:go_default_library", 19 | "@org_golang_x_oauth2//:go_default_library", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /google/backup.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package google 16 | 17 | import ( 18 | "bufio" 19 | "context" 20 | "fmt" 21 | "io" 22 | "log" 23 | "net/url" 24 | "os" 25 | "path" 26 | "path/filepath" 27 | "sort" 28 | "strconv" 29 | "strings" 30 | "time" 31 | 32 | "cloud.google.com/go/storage" 33 | "github.com/google/goblet" 34 | "google.golang.org/api/iterator" 35 | ) 36 | 37 | const ( 38 | gobletRepoManifestDir = "goblet-repository-manifests" 39 | 40 | manifestCleanUpDuration = 24 * time.Hour 41 | 42 | backupFrequency = time.Hour 43 | ) 44 | 45 | func RunBackupProcess(config *goblet.ServerConfig, bh *storage.BucketHandle, manifestName string, logger *log.Logger) { 46 | rw := &backupReaderWriter{ 47 | bucketHandle: bh, 48 | manifestName: manifestName, 49 | config: config, 50 | logger: logger, 51 | } 52 | rw.recoverFromBackup() 53 | go func() { 54 | timer := time.NewTimer(backupFrequency) 55 | for { 56 | select { 57 | case <-timer.C: 58 | rw.saveBackup() 59 | } 60 | timer.Reset(backupFrequency) 61 | } 62 | }() 63 | } 64 | 65 | type backupReaderWriter struct { 66 | bucketHandle *storage.BucketHandle 67 | manifestName string 68 | config *goblet.ServerConfig 69 | logger *log.Logger 70 | } 71 | 72 | func (b *backupReaderWriter) recoverFromBackup() { 73 | repos := b.readRepoList() 74 | if repos == nil || len(repos) == 0 { 75 | b.logger.Print("No repositories found from backup") 76 | return 77 | } 78 | 79 | for rawURL, _ := range repos { 80 | u, err := url.Parse(rawURL) 81 | if err != nil { 82 | b.logger.Printf("Cannot parse %s as a URL. Skipping", rawURL) 83 | continue 84 | } 85 | 86 | bundlePath, err := b.downloadBackupBundle(path.Join(u.Host, u.Path)) 87 | if err != nil { 88 | b.logger.Printf("Cannot find the backup bundle for %s. Skipping: %v", rawURL, err) 89 | continue 90 | } 91 | 92 | m, err := goblet.OpenManagedRepository(b.config, u) 93 | if err != nil { 94 | b.logger.Printf("Cannot open a managed repository for %s. Skipping: %v", rawURL, err) 95 | continue 96 | } 97 | 98 | m.RecoverFromBundle(bundlePath) 99 | os.Remove(bundlePath) 100 | } 101 | } 102 | 103 | func (b *backupReaderWriter) readRepoList() map[string]bool { 104 | it := b.bucketHandle.Objects(context.Background(), &storage.Query{ 105 | Delimiter: "/", 106 | Prefix: path.Join(gobletRepoManifestDir, b.manifestName) + "/", 107 | }) 108 | repos := map[string]bool{} 109 | for { 110 | attrs, err := it.Next() 111 | if err == iterator.Done { 112 | break 113 | } 114 | if err != nil { 115 | b.logger.Printf("Error while finding the manifests: %v", err) 116 | return nil 117 | } 118 | if attrs.Name == "" { 119 | continue 120 | } 121 | 122 | b.readManifest(attrs.Name, repos) 123 | } 124 | return repos 125 | } 126 | 127 | func (b *backupReaderWriter) readManifest(name string, m map[string]bool) { 128 | rc, err := b.bucketHandle.Object(name).NewReader(context.Background()) 129 | if err != nil { 130 | b.logger.Printf("Cannot open a manifest file %s. Skipping: %v", name, err) 131 | return 132 | } 133 | defer rc.Close() 134 | 135 | sc := bufio.NewScanner(rc) 136 | for sc.Scan() { 137 | m[strings.TrimSpace(sc.Text())] = true 138 | } 139 | if err := sc.Err(); err != nil { 140 | b.logger.Printf("Error while reading a manifest file %s. Skipping the rest of the file: %v", name, err) 141 | } 142 | } 143 | 144 | func (b *backupReaderWriter) downloadBackupBundle(name string) (string, error) { 145 | _, name, err := b.gcBundle(name) 146 | if name == "" { 147 | return "", fmt.Errorf("cannot find the bundle for %s: %v", name, err) 148 | } 149 | 150 | rc, err := b.bucketHandle.Object(name).NewReader(context.Background()) 151 | if err != nil { 152 | return "", err 153 | } 154 | defer rc.Close() 155 | 156 | tmpBundlePath := filepath.Join(b.config.LocalDiskCacheRoot, "tmp-bundle") 157 | fi, err := os.OpenFile(tmpBundlePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) 158 | if err != nil { 159 | return "", err 160 | } 161 | defer fi.Close() 162 | 163 | if _, err := io.Copy(fi, rc); err != nil { 164 | return "", err 165 | } 166 | return tmpBundlePath, nil 167 | } 168 | 169 | func (b *backupReaderWriter) saveBackup() { 170 | urls := []string{} 171 | goblet.ListManagedRepositories(func(m goblet.ManagedRepository) { 172 | u := m.UpstreamURL() 173 | latestBundleSecPrecision, _, err := b.gcBundle(path.Join(u.Host, u.Path)) 174 | if err != nil { 175 | b.logger.Printf("cannot GC bundles for %s. Skipping: %v", u.String(), err) 176 | return 177 | } 178 | // The bundle timestmap is seconds precision. 179 | if latestBundleSecPrecision.Unix() >= m.LastUpdateTime().Unix() { 180 | b.logger.Printf("existing bundle for %s is up-to-date %s", u.String(), latestBundleSecPrecision.Format(time.RFC3339)) 181 | } else if err := b.backupManagedRepo(m); err != nil { 182 | b.logger.Printf("cannot make a backup for %s. Skipping: %v", u.String(), err) 183 | return 184 | } 185 | 186 | urls = append(urls, u.String()) 187 | }) 188 | 189 | now := time.Now() 190 | manifestFile := path.Join(gobletRepoManifestDir, b.manifestName, fmt.Sprintf("%012d", now.Unix())) 191 | if err := b.writeManifestFile(manifestFile, urls); err != nil { 192 | b.logger.Printf("cannot create %s: %v", manifestFile, err) 193 | return 194 | } 195 | 196 | b.garbageCollectOldManifests(now) 197 | } 198 | 199 | func (b *backupReaderWriter) gcBundle(name string) (time.Time, string, error) { 200 | names := []string{} 201 | it := b.bucketHandle.Objects(context.Background(), &storage.Query{ 202 | Delimiter: "/", 203 | Prefix: name + "/", 204 | }) 205 | for { 206 | attrs, err := it.Next() 207 | if err == iterator.Done { 208 | break 209 | } 210 | if err != nil { 211 | return time.Time{}, "", fmt.Errorf("error while finding the bundles to GC: %v", err) 212 | } 213 | if attrs.Name == "" { 214 | continue 215 | } 216 | 217 | names = append(names, attrs.Name) 218 | } 219 | 220 | bundles := []string{} 221 | for _, name := range names { 222 | // Ignore non-bundles. 223 | if _, err := strconv.ParseInt(path.Base(names[0]), 10, 64); err != nil { 224 | continue 225 | } 226 | bundles = append(bundles, name) 227 | } 228 | 229 | if len(bundles) == 0 { 230 | // No backup found. 231 | return time.Time{}, "", nil 232 | } 233 | sort.Sort(sort.Reverse(sort.StringSlice(bundles))) 234 | 235 | for _, name := range bundles[1:len(bundles)] { 236 | b.bucketHandle.Object(name).Delete(context.Background()) 237 | } 238 | n, _ := strconv.ParseInt(path.Base(bundles[0]), 10, 64) 239 | return time.Unix(n, 0), bundles[0], nil 240 | } 241 | 242 | func (b *backupReaderWriter) backupManagedRepo(m goblet.ManagedRepository) error { 243 | u := m.UpstreamURL() 244 | bundleFile := path.Join(u.Host, u.Path, fmt.Sprintf("%012d", m.LastUpdateTime().Unix())) 245 | 246 | ctx, cf := context.WithCancel(context.Background()) 247 | defer cf() 248 | 249 | wc := b.bucketHandle.Object(bundleFile).NewWriter(ctx) 250 | if err := m.WriteBundle(wc); err != nil { 251 | return err 252 | } 253 | // Closing here will commit the file. Otherwise, the cancelled context 254 | // will discard the file. 255 | wc.Close() 256 | return nil 257 | } 258 | 259 | func (b *backupReaderWriter) writeManifestFile(manifestFile string, urls []string) error { 260 | ctx, cf := context.WithCancel(context.Background()) 261 | defer cf() 262 | 263 | wc := b.bucketHandle.Object(manifestFile).NewWriter(ctx) 264 | for _, url := range urls { 265 | if _, err := io.WriteString(wc, url+"\n"); err != nil { 266 | return err 267 | } 268 | } 269 | // Closing here will commit the file. Otherwise, the cancelled context 270 | // will discard the file. 271 | wc.Close() 272 | return nil 273 | } 274 | 275 | func (b *backupReaderWriter) garbageCollectOldManifests(now time.Time) { 276 | threshold := now.Add(-manifestCleanUpDuration) 277 | it := b.bucketHandle.Objects(context.Background(), &storage.Query{ 278 | Delimiter: "/", 279 | Prefix: path.Join(gobletRepoManifestDir, b.manifestName) + "/", 280 | }) 281 | for { 282 | attrs, err := it.Next() 283 | if err == iterator.Done { 284 | break 285 | } 286 | if err != nil { 287 | b.logger.Printf("Error while finding the manifests to GC: %v", err) 288 | return 289 | } 290 | if attrs.Prefix != "" { 291 | continue 292 | } 293 | 294 | sec, err := strconv.ParseInt(path.Base(attrs.Name), 10, 64) 295 | if err != nil { 296 | continue 297 | } 298 | t := time.Unix(sec, 0) 299 | if t.Before(threshold) { 300 | b.bucketHandle.Object(attrs.Name).Delete(context.Background()) 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /google/hooks.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package google 16 | 17 | import ( 18 | "context" 19 | "encoding/base64" 20 | "fmt" 21 | "net/http" 22 | "net/url" 23 | "strings" 24 | 25 | "golang.org/x/oauth2" 26 | oauth2cli "google.golang.org/api/oauth2/v2" 27 | "google.golang.org/api/option" 28 | "google.golang.org/grpc/codes" 29 | "google.golang.org/grpc/status" 30 | ) 31 | 32 | const ( 33 | scopeCloudPlatform = "https://www.googleapis.com/auth/cloud-platform" 34 | scopeUserInfoEmail = "https://www.googleapis.com/auth/userinfo.email" 35 | ) 36 | 37 | // NewRequestAuthorizer returns a function that checks the authorization header 38 | // and authorize the request. 39 | func NewRequestAuthorizer(ts oauth2.TokenSource) (func(*http.Request) error, error) { 40 | // Restrict the access to the proxy to the same user as the server's 41 | // service account. This makes sure that the server won't expose the 42 | // contents that the proxy clients cannot access, and the access 43 | // auditing is done properly. 44 | 45 | oauth2Service, err := oauth2cli.NewService(context.Background(), option.WithTokenSource(ts)) 46 | if err != nil { 47 | return nil, fmt.Errorf("cannot initialize the OAuth2 service: %v", err) 48 | } 49 | 50 | // Get the server's service account. 51 | t, err := ts.Token() 52 | if err != nil { 53 | return nil, fmt.Errorf("cannot obtain an OAuth2 access token for the server: %v", err) 54 | } 55 | c := oauth2Service.Tokeninfo() 56 | c.AccessToken(t.AccessToken) 57 | ti, err := c.Do() 58 | if err != nil { 59 | return nil, fmt.Errorf("failed to call OAuth2 TokenInfo: %v", err) 60 | } 61 | 62 | // Check that the server setup is correct. 63 | hasCloudPlatform, hasUserInfoEmail := scopeCheck(ti.Scope) 64 | if !hasCloudPlatform { 65 | return nil, fmt.Errorf("the server credential doesn't have %s scope. This is needed to access upstream repositories.", scopeCloudPlatform) 66 | } 67 | if !hasUserInfoEmail { 68 | return nil, fmt.Errorf("the server credential doesn't have %s scope. This is needed to get the email address of the service account.", scopeUserInfoEmail) 69 | } 70 | if ti.Email == "" { 71 | return nil, fmt.Errorf("cannot obtain the server's service account email") 72 | } 73 | 74 | email := ti.Email 75 | return func(r *http.Request) error { 76 | if h := r.Header.Get("Authorization"); h != "" { 77 | return authorizeAuthzHeader(oauth2Service, email, h) 78 | } 79 | if c, err := r.Cookie("o"); err == nil { 80 | return authorizeCookie(oauth2Service, email, c.Value) 81 | } 82 | return status.Error(codes.Unauthenticated, "no auth token") 83 | }, nil 84 | } 85 | 86 | func authorizeAuthzHeader(oauth2Service *oauth2cli.Service, email, authorizationHeader string) error { 87 | accessToken := "" 88 | if strings.HasPrefix(authorizationHeader, "Bearer ") { 89 | accessToken = strings.TrimPrefix(authorizationHeader, "Bearer ") 90 | } else if strings.HasPrefix(authorizationHeader, "Basic ") { 91 | bs, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(authorizationHeader, "Basic ")) 92 | if err != nil { 93 | return status.Error(codes.Unauthenticated, "cannot parse the Authorization header") 94 | } 95 | s := string(bs) 96 | i := strings.IndexByte(s, ':') 97 | if i < 0 { 98 | return status.Error(codes.Unauthenticated, "cannot parse the Authorization header") 99 | } 100 | accessToken = s[i+1:] 101 | } else { 102 | return status.Error(codes.Unauthenticated, "no bearer token") 103 | } 104 | return authorizeAccessToken(oauth2Service, email, accessToken) 105 | } 106 | 107 | func authorizeCookie(oauth2Service *oauth2cli.Service, email, oCookie string) error { 108 | if strings.ContainsRune(oCookie, '=') { 109 | oCookie = strings.SplitN(oCookie, "=", 2)[1] 110 | } 111 | return authorizeAccessToken(oauth2Service, email, oCookie) 112 | } 113 | 114 | func authorizeAccessToken(oauth2Service *oauth2cli.Service, email, accessToken string) error { 115 | c := oauth2Service.Tokeninfo() 116 | c.AccessToken(accessToken) 117 | ti, err := c.Do() 118 | if err != nil { 119 | return status.Errorf(codes.Unavailable, "cannot call OAuth2 TokenInfo: %v", err) 120 | } 121 | 122 | hasCloudPlatform, hasUserInfoEmail := scopeCheck(ti.Scope) 123 | if !hasCloudPlatform { 124 | return status.Errorf(codes.Unauthenticated, "access token doesn't have %s", scopeCloudPlatform) 125 | } 126 | if !hasUserInfoEmail { 127 | return status.Errorf(codes.Unauthenticated, "access token doesn't have %s", scopeUserInfoEmail) 128 | } 129 | 130 | if ti.Email != email { 131 | // Do not send the server's service account email so that a 132 | // stranger cannot know the server's service account. The proxy 133 | // server should be running in a private network, but this is 134 | // an extra protection. 135 | return status.Errorf(codes.Unauthenticated, "access token attests a different user %s", ti.Email) 136 | } 137 | 138 | return nil 139 | } 140 | 141 | // CanonicalizeURL returns a canonicalized URL for googlesource.com and source.developers.google.com. 142 | func CanonicalizeURL(u *url.URL) (*url.URL, error) { 143 | ret := url.URL{} 144 | ret.Scheme = "https" 145 | ret.Host = u.Host 146 | ret.Path = u.Path 147 | 148 | if strings.HasSuffix(ret.Host, ".googlesource.com") { 149 | if strings.HasPrefix(ret.Path, "/a/") { 150 | // Force authorization prefix. 151 | ret.Path = strings.TrimPrefix(ret.Path, "/a") 152 | } 153 | } else if ret.Host == "source.developers.google.com" { 154 | // Do nothing. 155 | } else { 156 | return nil, status.Errorf(codes.InvalidArgument, "unsupported host: %s", u.Host) 157 | } 158 | // Git endpoint suffixes. 159 | if strings.HasSuffix(ret.Path, "/info/refs") { 160 | ret.Path = strings.TrimSuffix(ret.Path, "/info/refs") 161 | } else if strings.HasSuffix(ret.Path, "/git-upload-pack") { 162 | ret.Path = strings.TrimSuffix(ret.Path, "/git-upload-pack") 163 | } else if strings.HasSuffix(ret.Path, "/git-receive-pack") { 164 | ret.Path = strings.TrimSuffix(ret.Path, "/git-receive-pack") 165 | } 166 | ret.Path = strings.TrimSuffix(ret.Path, ".git") 167 | return &ret, nil 168 | } 169 | 170 | func scopeCheck(scopes string) (bool, bool) { 171 | hasCloudPlatform := false 172 | hasUserInfoEmail := false 173 | for _, scope := range strings.Split(scopes, " ") { 174 | if scope == scopeCloudPlatform { 175 | hasCloudPlatform = true 176 | } 177 | if scope == scopeUserInfoEmail { 178 | hasUserInfoEmail = true 179 | } 180 | } 181 | return hasCloudPlatform, hasUserInfoEmail 182 | } 183 | -------------------------------------------------------------------------------- /http_proxy_server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "compress/gzip" 19 | "io" 20 | "net/http" 21 | "strings" 22 | 23 | "github.com/google/gitprotocolio" 24 | "go.opencensus.io/tag" 25 | "google.golang.org/grpc/codes" 26 | "google.golang.org/grpc/status" 27 | ) 28 | 29 | type httpProxyServer struct { 30 | config *ServerConfig 31 | } 32 | 33 | func (s *httpProxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { 34 | w, logCloser := logHTTPRequest(s.config, w, r) 35 | defer logCloser() 36 | reporter := &httpErrorReporter{config: s.config, req: r, w: w} 37 | 38 | ctx, err := tag.New(r.Context(), tag.Insert(CommandTypeKey, "not-a-command")) 39 | if err != nil { 40 | reporter.reportError(err) 41 | return 42 | } 43 | r = r.WithContext(ctx) 44 | 45 | // Technically, this server is an HTTP proxy, and it should use 46 | // Proxy-Authorization / Proxy-Authenticate. However, existing 47 | // authentication mechanism around Git is not compatible with proxy 48 | // authorization. We use normal authentication mechanism here. 49 | if err := s.config.RequestAuthorizer(r); err != nil { 50 | reporter.reportError(err) 51 | return 52 | } 53 | if proto := r.Header.Get("Git-Protocol"); proto != "version=2" { 54 | reporter.reportError(status.Error(codes.InvalidArgument, "accepts only Git protocol v2")) 55 | return 56 | } 57 | 58 | switch { 59 | case strings.HasSuffix(r.URL.Path, "/info/refs"): 60 | s.infoRefsHandler(reporter, w, r) 61 | case strings.HasSuffix(r.URL.Path, "/git-receive-pack"): 62 | reporter.reportError(status.Error(codes.Unimplemented, "git-receive-pack not supported")) 63 | case strings.HasSuffix(r.URL.Path, "/git-upload-pack"): 64 | s.uploadPackHandler(reporter, w, r) 65 | } 66 | } 67 | 68 | func (s *httpProxyServer) infoRefsHandler(reporter *httpErrorReporter, w http.ResponseWriter, r *http.Request) { 69 | if r.URL.Query().Get("service") != "git-upload-pack" { 70 | reporter.reportError(status.Error(codes.InvalidArgument, "accepts only git-fetch")) 71 | return 72 | } 73 | 74 | w.Header().Add("Content-Type", "application/x-git-upload-pack-advertisement") 75 | rs := []*gitprotocolio.InfoRefsResponseChunk{ 76 | {ProtocolVersion: 2}, 77 | {Capabilities: []string{"ls-refs"}}, 78 | // See managed_repositories.go for not having ref-in-want. 79 | {Capabilities: []string{"fetch=filter shallow"}}, 80 | {Capabilities: []string{"server-option"}}, 81 | {EndOfRequest: true}, 82 | } 83 | for _, pkt := range rs { 84 | if err := writePacket(w, pkt); err != nil { 85 | // Client-side IO error. Treat this as Canceled. 86 | reporter.reportError(status.Errorf(codes.Canceled, "client IO error")) 87 | return 88 | } 89 | } 90 | } 91 | 92 | func (s *httpProxyServer) uploadPackHandler(reporter *httpErrorReporter, w http.ResponseWriter, r *http.Request) { 93 | // /git-upload-pack doesn't recognize text/plain error. Send an error 94 | // with ErrorPacket. 95 | w.Header().Add("Content-Type", "application/x-git-upload-pack-result") 96 | if r.Header.Get("Content-Encoding") == "gzip" { 97 | var err error 98 | if r.Body, err = gzip.NewReader(r.Body); err != nil { 99 | reporter.reportError(status.Errorf(codes.InvalidArgument, "cannot ungzip: %v", err)) 100 | return 101 | } 102 | } 103 | 104 | // HTTP is strictly speaking a request-response protocol, and a server 105 | // cannot send a non-error response until the entire request is read. 106 | // We need to compromise and either drain the entire request first or 107 | // buffer the entire response. 108 | // 109 | // Because this server supports only ls-refs and fetch commands, valid 110 | // protocol V2 requests are relatively small in practice compared to the 111 | // response. A request with many wants and haves can be large, but 112 | // practically there's a limit on the number of haves a client would 113 | // send. Compared to that the fetch response can contain a packfile, and 114 | // this can easily get large. Read the entire request upfront. 115 | commands, err := parseAllCommands(r.Body) 116 | if err != nil { 117 | reporter.reportError(err) 118 | return 119 | } 120 | 121 | repo, err := openManagedRepository(s.config, r.URL) 122 | if err != nil { 123 | reporter.reportError(err) 124 | return 125 | } 126 | 127 | gitReporter := &gitProtocolHTTPErrorReporter{config: s.config, req: r, w: w} 128 | for _, command := range commands { 129 | if !handleV2Command(r.Context(), gitReporter, repo, command, w) { 130 | return 131 | } 132 | } 133 | } 134 | 135 | func parseAllCommands(r io.Reader) ([][]*gitprotocolio.ProtocolV2RequestChunk, error) { 136 | commands := [][]*gitprotocolio.ProtocolV2RequestChunk{} 137 | v2Req := gitprotocolio.NewProtocolV2Request(r) 138 | for { 139 | chunks := []*gitprotocolio.ProtocolV2RequestChunk{} 140 | for v2Req.Scan() { 141 | c := copyRequestChunk(v2Req.Chunk()) 142 | if c.EndRequest { 143 | break 144 | } 145 | chunks = append(chunks, c) 146 | } 147 | if len(chunks) == 0 || v2Req.Err() != nil { 148 | break 149 | } 150 | 151 | switch chunks[0].Command { 152 | case "ls-refs": 153 | case "fetch": 154 | // Do nothing. 155 | default: 156 | return nil, status.Errorf(codes.InvalidArgument, "unrecognized command: %v", chunks[0]) 157 | } 158 | commands = append(commands, chunks) 159 | } 160 | 161 | if err := v2Req.Err(); err != nil { 162 | return nil, status.Errorf(codes.InvalidArgument, "cannot parse the request: %v", err) 163 | } 164 | return commands, nil 165 | } 166 | -------------------------------------------------------------------------------- /io.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "io" 19 | 20 | "github.com/google/gitprotocolio" 21 | ) 22 | 23 | func writePacket(w io.Writer, p gitprotocolio.Packet) error { 24 | _, err := w.Write(p.EncodeToPktLine()) 25 | return err 26 | } 27 | 28 | func writeResp(w io.Writer, chunks []*gitprotocolio.ProtocolV2ResponseChunk) error { 29 | for _, chunk := range chunks { 30 | if err := writePacket(w, chunk); err != nil { 31 | return err 32 | } 33 | } 34 | return nil 35 | } 36 | 37 | func writeError(w io.Writer, err error) error { 38 | return writePacket(w, gitprotocolio.ErrorPacket(err.Error())) 39 | } 40 | 41 | func copyRequestChunk(c *gitprotocolio.ProtocolV2RequestChunk) *gitprotocolio.ProtocolV2RequestChunk { 42 | r := *c 43 | if r.Argument != nil { 44 | b := make([]byte, len(r.Argument)) 45 | copy(b, r.Argument) 46 | r.Argument = b 47 | } 48 | return &r 49 | } 50 | 51 | func copyResponseChunk(c *gitprotocolio.ProtocolV2ResponseChunk) *gitprotocolio.ProtocolV2ResponseChunk { 52 | r := *c 53 | if r.Response != nil { 54 | b := make([]byte, len(r.Response)) 55 | copy(b, r.Response) 56 | r.Response = b 57 | } 58 | return &r 59 | } 60 | -------------------------------------------------------------------------------- /managed_repository.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "bytes" 19 | "context" 20 | "fmt" 21 | "io" 22 | "io/ioutil" 23 | "log" 24 | "net/http" 25 | "net/url" 26 | "os" 27 | "os/exec" 28 | "path/filepath" 29 | "strings" 30 | "sync" 31 | "time" 32 | 33 | "github.com/go-git/go-git/v5" 34 | "github.com/go-git/go-git/v5/plumbing" 35 | "github.com/google/gitprotocolio" 36 | "go.opencensus.io/stats" 37 | "go.opencensus.io/tag" 38 | "golang.org/x/oauth2" 39 | "google.golang.org/grpc/codes" 40 | "google.golang.org/grpc/status" 41 | ) 42 | 43 | var ( 44 | gitBinary string 45 | // *managedRepository map keyed by a cached repository path. 46 | managedRepos sync.Map 47 | ) 48 | 49 | func init() { 50 | var err error 51 | gitBinary, err = exec.LookPath("git") 52 | if err != nil { 53 | log.Fatal("Cannot find the git binary: ", err) 54 | } 55 | } 56 | 57 | func getManagedRepo(localDiskPath string, u *url.URL, config *ServerConfig) *managedRepository { 58 | newM := &managedRepository{ 59 | localDiskPath: localDiskPath, 60 | upstreamURL: u, 61 | config: config, 62 | } 63 | newM.mu.Lock() 64 | m, loaded := managedRepos.LoadOrStore(localDiskPath, newM) 65 | ret := m.(*managedRepository) 66 | if !loaded { 67 | ret.mu.Unlock() 68 | } 69 | return ret 70 | } 71 | 72 | func openManagedRepository(config *ServerConfig, u *url.URL) (*managedRepository, error) { 73 | u, err := config.URLCanonializer(u) 74 | if err != nil { 75 | return nil, err 76 | } 77 | 78 | localDiskPath := filepath.Join(config.LocalDiskCacheRoot, u.Host, u.Path) 79 | 80 | m := getManagedRepo(localDiskPath, u, config) 81 | m.mu.Lock() 82 | defer m.mu.Unlock() 83 | 84 | if _, err := os.Stat(localDiskPath); err != nil { 85 | if !os.IsNotExist(err) { 86 | return nil, status.Errorf(codes.Internal, "error while initializing local Git repoitory: %v", err) 87 | } 88 | 89 | if err := os.MkdirAll(localDiskPath, 0750); err != nil { 90 | return nil, status.Errorf(codes.Internal, "cannot create a cache dir: %v", err) 91 | } 92 | 93 | op := noopOperation{} 94 | runGit(op, localDiskPath, "init", "--bare") 95 | runGit(op, localDiskPath, "config", "protocol.version", "2") 96 | runGit(op, localDiskPath, "config", "uploadpack.allowfilter", "1") 97 | runGit(op, localDiskPath, "config", "uploadpack.allowrefinwant", "1") 98 | runGit(op, localDiskPath, "config", "repack.writebitmaps", "1") 99 | // It seems there's a bug in libcurl and HTTP/2 doens't work. 100 | runGit(op, localDiskPath, "config", "http.version", "HTTP/1.1") 101 | runGit(op, localDiskPath, "remote", "add", "--mirror=fetch", "origin", u.String()) 102 | } 103 | 104 | return m, nil 105 | } 106 | 107 | func logStats(command string, startTime time.Time, err error) { 108 | code := codes.Unavailable 109 | if st, ok := status.FromError(err); ok { 110 | code = st.Code() 111 | } 112 | stats.RecordWithTags(context.Background(), 113 | []tag.Mutator{ 114 | tag.Insert(CommandTypeKey, command), 115 | tag.Insert(CommandCanonicalStatusKey, code.String()), 116 | }, 117 | OutboundCommandCount.M(1), 118 | OutboundCommandProcessingTime.M(int64(time.Now().Sub(startTime)/time.Millisecond)), 119 | ) 120 | } 121 | 122 | type managedRepository struct { 123 | localDiskPath string 124 | lastUpdate time.Time 125 | upstreamURL *url.URL 126 | config *ServerConfig 127 | mu sync.RWMutex 128 | } 129 | 130 | func (r *managedRepository) lsRefsUpstream(command []*gitprotocolio.ProtocolV2RequestChunk) ([]*gitprotocolio.ProtocolV2ResponseChunk, error) { 131 | req, err := http.NewRequest("POST", r.upstreamURL.String()+"/git-upload-pack", newGitRequest(command)) 132 | if err != nil { 133 | return nil, status.Errorf(codes.Internal, "cannot construct a request object: %v", err) 134 | } 135 | t, err := r.config.TokenSource.Token() 136 | if err != nil { 137 | return nil, status.Errorf(codes.Internal, "cannot obtain an OAuth2 access token for the server: %v", err) 138 | } 139 | req.Header.Add("Content-Type", "application/x-git-upload-pack-request") 140 | req.Header.Add("Accept", "application/x-git-upload-pack-result") 141 | req.Header.Add("Git-Protocol", "version=2") 142 | t.SetAuthHeader(req) 143 | 144 | startTime := time.Now() 145 | resp, err := http.DefaultClient.Do(req) 146 | logStats("ls-refs", startTime, err) 147 | if err != nil { 148 | return nil, status.Errorf(codes.Internal, "cannot send a request to the upstream: %v", err) 149 | } 150 | defer resp.Body.Close() 151 | if resp.StatusCode != http.StatusOK { 152 | errMessage := "" 153 | if strings.HasPrefix(resp.Header.Get("Content-Type"), "text/plain") { 154 | bs, err := ioutil.ReadAll(resp.Body) 155 | if err == nil { 156 | errMessage = string(bs) 157 | } 158 | } 159 | return nil, fmt.Errorf("got a non-OK response from the upstream: %v %s", resp.StatusCode, errMessage) 160 | } 161 | 162 | chunks := []*gitprotocolio.ProtocolV2ResponseChunk{} 163 | v2Resp := gitprotocolio.NewProtocolV2Response(resp.Body) 164 | for v2Resp.Scan() { 165 | chunks = append(chunks, copyResponseChunk(v2Resp.Chunk())) 166 | } 167 | if err := v2Resp.Err(); err != nil { 168 | return nil, fmt.Errorf("cannot parse the upstream response: %v", err) 169 | } 170 | return chunks, nil 171 | } 172 | 173 | func (r *managedRepository) fetchUpstream() (err error) { 174 | op := r.startOperation("FetchUpstream") 175 | defer func() { 176 | op.Done(err) 177 | }() 178 | 179 | // Because of 180 | // https://public-inbox.org/git/20190915211802.207715-1-masayasuzuki@google.com/T/#t, 181 | // the initial git-fetch can be very slow. Split the fetch if there's no 182 | // reference (== an empty repo). 183 | g, err := git.PlainOpen(r.localDiskPath) 184 | if err != nil { 185 | return fmt.Errorf("cannot open the local cached repository: %v", err) 186 | } 187 | splitGitFetch := false 188 | if _, err := g.Reference("HEAD", true); err == plumbing.ErrReferenceNotFound { 189 | splitGitFetch = true 190 | } 191 | 192 | var t *oauth2.Token 193 | startTime := time.Now() 194 | r.mu.Lock() 195 | defer r.mu.Unlock() 196 | if splitGitFetch { 197 | // Fetch heads and changes first. 198 | t, err = r.config.TokenSource.Token() 199 | if err != nil { 200 | err = status.Errorf(codes.Internal, "cannot obtain an OAuth2 access token for the server: %v", err) 201 | return err 202 | } 203 | err = runGit(op, r.localDiskPath, "-c", "http.extraHeader=Authorization: Bearer "+t.AccessToken, "fetch", "--progress", "-f", "-n", "origin", "refs/heads/*:refs/heads/*", "refs/changes/*:refs/changes/*") 204 | } 205 | if err == nil { 206 | t, err = r.config.TokenSource.Token() 207 | if err != nil { 208 | err = status.Errorf(codes.Internal, "cannot obtain an OAuth2 access token for the server: %v", err) 209 | return err 210 | } 211 | err = runGit(op, r.localDiskPath, "-c", "http.extraHeader=Authorization: Bearer "+t.AccessToken, "fetch", "--progress", "-f", "origin") 212 | } 213 | logStats("fetch", startTime, err) 214 | if err == nil { 215 | r.lastUpdate = startTime 216 | } 217 | return err 218 | } 219 | 220 | func (r *managedRepository) UpstreamURL() *url.URL { 221 | u := *r.upstreamURL 222 | return &u 223 | } 224 | 225 | func (r *managedRepository) LastUpdateTime() time.Time { 226 | r.mu.RLock() 227 | defer r.mu.RUnlock() 228 | return r.lastUpdate 229 | } 230 | 231 | func (r *managedRepository) RecoverFromBundle(bundlePath string) (err error) { 232 | op := r.startOperation("ReadBundle") 233 | defer func() { 234 | op.Done(err) 235 | }() 236 | 237 | r.mu.Lock() 238 | defer r.mu.Unlock() 239 | err = runGit(op, r.localDiskPath, "fetch", "--progress", "-f", bundlePath, "refs/*:refs/*") 240 | return 241 | } 242 | 243 | func (r *managedRepository) WriteBundle(w io.Writer) (err error) { 244 | op := r.startOperation("CreateBundle") 245 | defer func() { 246 | op.Done(err) 247 | }() 248 | err = runGitWithStdOut(op, w, r.localDiskPath, "bundle", "create", "-", "--all") 249 | return 250 | } 251 | 252 | func (r *managedRepository) hasAnyUpdate(refs map[string]plumbing.Hash) (bool, error) { 253 | g, err := git.PlainOpen(r.localDiskPath) 254 | if err != nil { 255 | return false, fmt.Errorf("cannot open the local cached repository: %v", err) 256 | } 257 | for refName, hash := range refs { 258 | ref, err := g.Reference(plumbing.ReferenceName(refName), true) 259 | if err == plumbing.ErrReferenceNotFound { 260 | return true, nil 261 | } else if err != nil { 262 | return false, fmt.Errorf("cannot open the reference: %v", err) 263 | } 264 | if ref.Hash() != hash { 265 | return true, nil 266 | } 267 | } 268 | return false, nil 269 | } 270 | 271 | func (r *managedRepository) hasAllWants(hashes []plumbing.Hash, refs []string) (bool, error) { 272 | g, err := git.PlainOpen(r.localDiskPath) 273 | if err != nil { 274 | return false, fmt.Errorf("cannot open the local cached repository: %v", err) 275 | } 276 | 277 | for _, hash := range hashes { 278 | if _, err := g.Object(plumbing.AnyObject, hash); err == plumbing.ErrObjectNotFound { 279 | return false, nil 280 | } else if err != nil { 281 | return false, fmt.Errorf("error while looking up an object for want check: %v", err) 282 | } 283 | } 284 | 285 | for _, refName := range refs { 286 | if _, err := g.Reference(plumbing.ReferenceName(refName), true); err == plumbing.ErrReferenceNotFound { 287 | return false, nil 288 | } else if err != nil { 289 | return false, fmt.Errorf("error while looking up a reference for want check: %v", err) 290 | } 291 | } 292 | 293 | return true, nil 294 | } 295 | 296 | func (r *managedRepository) serveFetchLocal(command []*gitprotocolio.ProtocolV2RequestChunk, w io.Writer) error { 297 | // If fetch-upstream is running, it's possible that Git returns 298 | // incomplete set of objects when the refs being fetched is updated and 299 | // it uses ref-in-want. 300 | cmd := exec.Command(gitBinary, "upload-pack", "--stateless-rpc", r.localDiskPath) 301 | cmd.Env = []string{"GIT_PROTOCOL=version=2"} 302 | cmd.Dir = r.localDiskPath 303 | cmd.Stdin = newGitRequest(command) 304 | cmd.Stdout = w 305 | cmd.Stderr = os.Stderr 306 | return cmd.Run() 307 | } 308 | 309 | func (r *managedRepository) startOperation(op string) RunningOperation { 310 | if r.config.LongRunningOperationLogger != nil { 311 | return r.config.LongRunningOperationLogger(op, r.upstreamURL) 312 | } 313 | return noopOperation{} 314 | } 315 | 316 | func runGit(op RunningOperation, gitDir string, arg ...string) error { 317 | cmd := exec.Command(gitBinary, arg...) 318 | cmd.Env = []string{} 319 | cmd.Dir = gitDir 320 | cmd.Stderr = &operationWriter{op} 321 | cmd.Stdout = &operationWriter{op} 322 | if err := cmd.Run(); err != nil { 323 | return fmt.Errorf("failed to run a git command: %v", err) 324 | } 325 | return nil 326 | } 327 | 328 | func runGitWithStdOut(op RunningOperation, w io.Writer, gitDir string, arg ...string) error { 329 | cmd := exec.Command(gitBinary, arg...) 330 | cmd.Env = []string{} 331 | cmd.Dir = gitDir 332 | cmd.Stdout = w 333 | cmd.Stderr = &operationWriter{op} 334 | if err := cmd.Run(); err != nil { 335 | return fmt.Errorf("failed to run a git command: %v", err) 336 | } 337 | return nil 338 | } 339 | 340 | func newGitRequest(command []*gitprotocolio.ProtocolV2RequestChunk) io.Reader { 341 | b := new(bytes.Buffer) 342 | for _, c := range command { 343 | b.Write(c.EncodeToPktLine()) 344 | } 345 | return b 346 | } 347 | 348 | type noopOperation struct{} 349 | 350 | func (noopOperation) Printf(string, ...interface{}) {} 351 | func (noopOperation) Done(error) {} 352 | 353 | type operationWriter struct { 354 | op RunningOperation 355 | } 356 | 357 | func (w *operationWriter) Write(p []byte) (int, error) { 358 | w.op.Printf("%s", string(p)) 359 | return len(p), nil 360 | } 361 | -------------------------------------------------------------------------------- /reporting.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package goblet 16 | 17 | import ( 18 | "context" 19 | "io" 20 | "log" 21 | "net/http" 22 | "time" 23 | 24 | "github.com/grpc-ecosystem/grpc-gateway/runtime" 25 | "go.opencensus.io/stats" 26 | "go.opencensus.io/tag" 27 | "google.golang.org/grpc/codes" 28 | "google.golang.org/grpc/status" 29 | ) 30 | 31 | var ( 32 | serverErrorCodes = map[codes.Code]bool{ 33 | codes.DataLoss: true, 34 | codes.DeadlineExceeded: true, 35 | codes.Internal: true, 36 | codes.Unavailable: true, 37 | codes.Unknown: true, 38 | } 39 | ) 40 | 41 | type httpErrorReporter struct { 42 | config *ServerConfig 43 | req *http.Request 44 | w http.ResponseWriter 45 | } 46 | 47 | func (h *httpErrorReporter) reportError(err error) { 48 | code := codes.Internal 49 | message := "" 50 | if st, ok := status.FromError(err); ok { 51 | code = st.Code() 52 | message = st.Message() 53 | } 54 | stats.RecordWithTags( 55 | h.req.Context(), 56 | []tag.Mutator{tag.Insert(CommandCanonicalStatusKey, code.String())}, 57 | InboundCommandCount.M(1), 58 | ) 59 | 60 | if code == codes.Unauthenticated { 61 | h.w.Header().Add("WWW-Authenticate", "Bearer") 62 | h.w.Header().Add("WWW-Authenticate", "Basic realm=goblet") 63 | } 64 | httpStatus := runtime.HTTPStatusFromCode(code) 65 | if message == "" { 66 | message = http.StatusText(httpStatus) 67 | } 68 | http.Error(h.w, message, httpStatus) 69 | 70 | if !serverErrorCodes[code] { 71 | return 72 | } 73 | 74 | if h.config.ErrorReporter != nil { 75 | h.config.ErrorReporter(h.req, err) 76 | return 77 | } 78 | log.Printf("Error while processing a request: %v", err) 79 | } 80 | 81 | type gitProtocolHTTPErrorReporter struct { 82 | config *ServerConfig 83 | req *http.Request 84 | w http.ResponseWriter 85 | } 86 | 87 | func (h *gitProtocolHTTPErrorReporter) reportError(ctx context.Context, startTime time.Time, err error) { 88 | code := codes.Internal 89 | if st, ok := status.FromError(err); ok { 90 | code = st.Code() 91 | } 92 | stats.RecordWithTags( 93 | ctx, 94 | []tag.Mutator{tag.Insert(CommandCanonicalStatusKey, code.String())}, 95 | InboundCommandCount.M(1), 96 | InboundCommandProcessingTime.M(int64(time.Now().Sub(startTime)/time.Millisecond)), 97 | ) 98 | 99 | if err != nil { 100 | writeError(h.w, err) 101 | } 102 | 103 | if !serverErrorCodes[code] { 104 | return 105 | } 106 | 107 | if h.config.ErrorReporter != nil { 108 | h.config.ErrorReporter(h.req.WithContext(ctx), err) 109 | return 110 | } 111 | log.Printf("Error while processing a request: %v", err) 112 | } 113 | 114 | func logHTTPRequest(config *ServerConfig, w http.ResponseWriter, r *http.Request) (http.ResponseWriter, func()) { 115 | startTime := time.Now() 116 | monR := &monitoringReader{r: r.Body} 117 | r.Body = monR 118 | 119 | monW := &monitoringWriter{w: w} 120 | if f, ok := w.(http.Flusher); ok { 121 | monW.flush = f.Flush 122 | } else { 123 | monW.flush = func() {} 124 | } 125 | 126 | return monW, func() { 127 | if config.RequestLogger == nil { 128 | return 129 | } 130 | endTime := time.Now() 131 | 132 | config.RequestLogger(r, monW.status, monR.bytesRead, monW.bytesWritten, endTime.Sub(startTime)) 133 | } 134 | } 135 | 136 | type monitoringReader struct { 137 | r io.ReadCloser 138 | bytesRead int64 139 | } 140 | 141 | func (r *monitoringReader) Read(p []byte) (int, error) { 142 | n, err := r.r.Read(p) 143 | r.bytesRead += int64(n) 144 | return n, err 145 | } 146 | 147 | func (r *monitoringReader) Close() error { 148 | return r.Close() 149 | } 150 | 151 | type monitoringWriter struct { 152 | status int 153 | w http.ResponseWriter 154 | flush func() 155 | bytesWritten int64 156 | } 157 | 158 | func (w *monitoringWriter) Flush() { 159 | w.flush() 160 | } 161 | 162 | func (w *monitoringWriter) Write(bs []byte) (n int, err error) { 163 | if w.status == 0 { 164 | w.status = http.StatusOK 165 | } 166 | n, err = w.w.Write(bs) 167 | w.bytesWritten += int64(len(bs)) 168 | w.flush() 169 | return 170 | } 171 | 172 | func (w *monitoringWriter) WriteHeader(status int) { 173 | w.status = status 174 | w.w.WriteHeader(status) 175 | } 176 | 177 | func (w *monitoringWriter) Header() http.Header { 178 | return w.w.Header() 179 | } 180 | -------------------------------------------------------------------------------- /testing/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["test_proxy_server.go"], 6 | importpath = "github.com/google/goblet/testing", 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "//:go_default_library", 10 | "@org_golang_google_grpc//codes:go_default_library", 11 | "@org_golang_google_grpc//status:go_default_library", 12 | "@org_golang_x_oauth2//:go_default_library", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /testing/end2end/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_test") 2 | 3 | go_test( 4 | name = "go_default_test", 5 | srcs = ["fetch_test.go"], 6 | deps = ["//testing:go_default_library"], 7 | ) 8 | -------------------------------------------------------------------------------- /testing/end2end/fetch_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package end2end 16 | 17 | import ( 18 | "testing" 19 | 20 | goblettest "github.com/google/goblet/testing" 21 | ) 22 | 23 | func TestFetch(t *testing.T) { 24 | ts := goblettest.NewTestServer(&goblettest.TestServerConfig{ 25 | RequestAuthorizer: goblettest.TestRequestAuthorizer, 26 | TokenSource: goblettest.TestTokenSource, 27 | }) 28 | defer ts.Close() 29 | 30 | want, err := ts.CreateRandomCommitUpstream() 31 | if err != nil { 32 | t.Fatal(err) 33 | } 34 | 35 | client := goblettest.NewLocalGitRepo() 36 | defer client.Close() 37 | if _, err := client.Run("-c", "http.extraHeader=Authorization: Bearer "+goblettest.ValidClientAuthToken, "fetch", ts.ProxyServerURL); err != nil { 38 | t.Fatal(err) 39 | } 40 | 41 | if got, err := client.Run("rev-parse", "FETCH_HEAD"); err != nil { 42 | t.Error(err) 43 | } else if got != want { 44 | t.Errorf("got %s, want %s", got, want) 45 | } 46 | } 47 | 48 | func TestFetch_ForceFetchUpdate(t *testing.T) { 49 | ts := goblettest.NewTestServer(&goblettest.TestServerConfig{ 50 | RequestAuthorizer: goblettest.TestRequestAuthorizer, 51 | TokenSource: goblettest.TestTokenSource, 52 | }) 53 | defer ts.Close() 54 | 55 | _, err := ts.CreateRandomCommitUpstream() 56 | if err != nil { 57 | t.Fatal(err) 58 | } 59 | 60 | client := goblettest.NewLocalGitRepo() 61 | defer client.Close() 62 | if _, err := client.Run("remote", "add", "origin", ts.ProxyServerURL); err != nil { 63 | t.Fatal(err) 64 | } 65 | if _, err := client.Run("-c", "http.extraHeader=Authorization: Bearer "+goblettest.ValidClientAuthToken, "fetch", "origin"); err != nil { 66 | t.Fatal(err) 67 | } 68 | 69 | want, err := ts.CreateRandomCommitUpstream() 70 | if err != nil { 71 | t.Fatal(err) 72 | } 73 | 74 | if _, err := client.Run("-c", "http.extraHeader=Authorization: Bearer "+goblettest.ValidClientAuthToken, "fetch", "origin", "master"); err != nil { 75 | t.Fatal(err) 76 | } 77 | 78 | if got, err := client.Run("rev-parse", "FETCH_HEAD"); err != nil { 79 | t.Error(err) 80 | } else if got != want { 81 | t.Errorf("got %s, want %s", got, want) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /testing/test_proxy_server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package testing 16 | 17 | import ( 18 | "fmt" 19 | "io/ioutil" 20 | "log" 21 | "net/http" 22 | "net/http/cgi" 23 | "net/http/httptest" 24 | "net/url" 25 | "os" 26 | "os/exec" 27 | "strings" 28 | "time" 29 | 30 | "github.com/google/goblet" 31 | "golang.org/x/oauth2" 32 | "google.golang.org/grpc/codes" 33 | "google.golang.org/grpc/status" 34 | ) 35 | 36 | const ( 37 | ValidClientAuthToken = "valid-client-auth-token" 38 | validServerAuthToken = "valid-server-auth-token" 39 | ) 40 | 41 | var ( 42 | gitBinary string 43 | 44 | TestTokenSource = oauth2.StaticTokenSource(&oauth2.Token{AccessToken: validServerAuthToken}) 45 | ) 46 | 47 | func init() { 48 | var err error 49 | gitBinary, err = exec.LookPath("git") 50 | if err != nil { 51 | log.Fatal("Cannot find the git binary: ", err) 52 | } 53 | } 54 | 55 | type TestServer struct { 56 | UpstreamGitRepo GitRepo 57 | upstreamServer *httptest.Server 58 | UpstreamServerURL string 59 | proxyServer *httptest.Server 60 | ProxyServerURL string 61 | } 62 | 63 | type TestServerConfig struct { 64 | RequestAuthorizer func(r *http.Request) error 65 | TokenSource oauth2.TokenSource 66 | ErrorReporter func(*http.Request, error) 67 | RequestLogger func(r *http.Request, status int, requestSize, responseSize int64, latency time.Duration) 68 | } 69 | 70 | func NewTestServer(config *TestServerConfig) *TestServer { 71 | s := &TestServer{} 72 | { 73 | s.UpstreamGitRepo = NewLocalBareGitRepo() 74 | s.UpstreamGitRepo.Run("config", "http.receivepack", "1") 75 | s.UpstreamGitRepo.Run("config", "uploadpack.allowfilter", "1") 76 | s.UpstreamGitRepo.Run("config", "receive.advertisepushoptions", "1") 77 | 78 | s.upstreamServer = httptest.NewServer(http.HandlerFunc(s.upstreamServerHandler)) 79 | s.UpstreamServerURL = s.upstreamServer.URL 80 | } 81 | 82 | { 83 | dir, err := ioutil.TempDir("", "goblet_cache") 84 | if err != nil { 85 | log.Fatal(err) 86 | } 87 | config := &goblet.ServerConfig{ 88 | LocalDiskCacheRoot: dir, 89 | URLCanonializer: s.testURLCanonicalizer, 90 | RequestAuthorizer: config.RequestAuthorizer, 91 | TokenSource: config.TokenSource, 92 | ErrorReporter: config.ErrorReporter, 93 | RequestLogger: config.RequestLogger, 94 | } 95 | s.proxyServer = httptest.NewServer(goblet.HTTPHandler(config)) 96 | s.ProxyServerURL = s.proxyServer.URL 97 | } 98 | return s 99 | } 100 | 101 | func (s *TestServer) testURLCanonicalizer(u *url.URL) (*url.URL, error) { 102 | ret, err := url.Parse(s.UpstreamServerURL) 103 | if err != nil { 104 | return nil, err 105 | } 106 | ret.Path = u.Path 107 | 108 | // Git endpoint suffixes. 109 | if strings.HasSuffix(ret.Path, "/info/refs") { 110 | ret.Path = strings.TrimSuffix(ret.Path, "/info/refs") 111 | } else if strings.HasSuffix(ret.Path, "/git-upload-pack") { 112 | ret.Path = strings.TrimSuffix(ret.Path, "/git-upload-pack") 113 | } else if strings.HasSuffix(ret.Path, "/git-receive-pack") { 114 | ret.Path = strings.TrimSuffix(ret.Path, "/git-receive-pack") 115 | } 116 | ret.Path = strings.TrimSuffix(ret.Path, ".git") 117 | return ret, nil 118 | } 119 | 120 | func (s *TestServer) upstreamServerHandler(w http.ResponseWriter, req *http.Request) { 121 | if req.Header.Get("Authorization") != "Bearer "+validServerAuthToken { 122 | http.Error(w, "invalid authenticator", http.StatusForbidden) 123 | return 124 | } 125 | 126 | h := &cgi.Handler{ 127 | Path: gitBinary, 128 | Dir: string(s.UpstreamGitRepo), 129 | Env: []string{ 130 | "GIT_PROJECT_ROOT=" + string(s.UpstreamGitRepo), 131 | "GIT_HTTP_EXPORT_ALL=1", 132 | }, 133 | Args: []string{ 134 | "http-backend", 135 | }, 136 | Stderr: os.Stderr, 137 | } 138 | if p := req.Header.Get("Git-Protocol"); p != "" { 139 | h.Env = append(h.Env, "GIT_PROTOCOL="+p) 140 | } 141 | if len(req.TransferEncoding) > 0 && req.TransferEncoding[0] == "chunked" { 142 | // Not sure why this restriction is in place in the 143 | // library. 144 | req.TransferEncoding = nil 145 | } 146 | h.ServeHTTP(w, req) 147 | } 148 | 149 | func (s *TestServer) CreateRandomCommitUpstream() (string, error) { 150 | pushClient := NewLocalGitRepo() 151 | defer pushClient.Close() 152 | hash, err := pushClient.CreateRandomCommit() 153 | if err != nil { 154 | return "", err 155 | } 156 | 157 | _, err = pushClient.Run("-c", "http.extraHeader=Authorization: Bearer "+validServerAuthToken, "push", "-f", s.UpstreamServerURL, "master:master") 158 | return hash, err 159 | 160 | } 161 | 162 | func (s *TestServer) Close() { 163 | s.upstreamServer.Close() 164 | s.proxyServer.Close() 165 | s.UpstreamGitRepo.Close() 166 | } 167 | 168 | func TestRequestAuthorizer(r *http.Request) error { 169 | authzHeader := r.Header.Get("Authorization") 170 | if authzHeader == "Bearer "+ValidClientAuthToken { 171 | return nil 172 | } 173 | return status.Errorf(codes.Unauthenticated, "not a valid client auth token: %s", authzHeader) 174 | } 175 | 176 | type GitRepo string 177 | 178 | func NewLocalBareGitRepo() GitRepo { 179 | dir, err := ioutil.TempDir("", "goblet_tmp") 180 | if err != nil { 181 | log.Fatal(err) 182 | } 183 | r := GitRepo(dir) 184 | r.Run("init", "--bare") 185 | return r 186 | } 187 | 188 | func NewLocalGitRepo() GitRepo { 189 | dir, err := ioutil.TempDir("", "goblet_tmp") 190 | if err != nil { 191 | log.Fatal(err) 192 | } 193 | r := GitRepo(dir) 194 | r.Run("init") 195 | r.Run("config", "user.email", "local-root@example.com") 196 | r.Run("config", "user.name", "local root") 197 | r.Run("config", "protocol.version", "2") 198 | return r 199 | } 200 | 201 | func (r GitRepo) Run(arg ...string) (string, error) { 202 | cmd := exec.Command(gitBinary, arg...) 203 | cmd.Dir = string(r) 204 | cmd.Env = []string{} 205 | bs, err := cmd.CombinedOutput() 206 | if err != nil { 207 | return "", &commandError{err, cmd.Args, strings.TrimRight(string(bs), "\n")} 208 | } 209 | return string(bs), nil 210 | } 211 | 212 | func (r GitRepo) CreateRandomCommit() (string, error) { 213 | if _, err := r.Run("commit", "--allow-empty", "--message="+time.Now().String()); err != nil { 214 | return "", err 215 | } 216 | return r.Run("rev-parse", "master") 217 | } 218 | 219 | func (r GitRepo) Close() error { 220 | return os.RemoveAll(string(r)) 221 | } 222 | 223 | type commandError struct { 224 | err error 225 | args []string 226 | output string 227 | } 228 | 229 | func (c *commandError) Error() string { 230 | ss := []string{ 231 | "cannot execute a git command", 232 | fmt.Sprintf("Error: %v", c.err), 233 | fmt.Sprintf("Args: %#v", c.args), 234 | } 235 | for _, s := range strings.Split(c.output, "\n") { 236 | ss = append(ss, "Output: "+s) 237 | } 238 | return strings.Join(ss, "\n") 239 | } 240 | --------------------------------------------------------------------------------