|
| 1 | +package main |
| 2 | + |
| 3 | +import "github.com/creachadair/command" |
| 4 | + |
| 5 | +var helpTopics = []command.HelpTopic{ |
| 6 | + { |
| 7 | + Name: "configure", |
| 8 | + Help: `How to configure the plugin. |
| 9 | +
|
| 10 | +To run the plugin, install the program somewhere on your system and set the |
| 11 | +GOCACHEPROG environment variable to the command line of the plugin. You can |
| 12 | +either specify the full path to the program, or install it in your $PATH. |
| 13 | +
|
| 14 | +Parameters can be passed either as flags or via environment variables. |
| 15 | +See also "help environment". |
| 16 | +
|
| 17 | +The plugin requires credentials to access S3. If you are running in AWS, it can |
| 18 | +get credentials from the instnce metadata service; otherwise you will need to |
| 19 | +plumb AWS environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or |
| 20 | +set up a configuration file. |
| 21 | +
|
| 22 | +------------------------------------------------------------------------ |
| 23 | +## To run the plugin directly as a subprocess of the toolchain |
| 24 | +
|
| 25 | + export GOCACHEPROG="go-cache-plugin --cache-dir=/tmp/gocache --bucket ..." |
| 26 | + go build ... |
| 27 | +
|
| 28 | + Alternatively: |
| 29 | +
|
| 30 | + export GOCACHE_DIR=/tmp/gocache |
| 31 | + export GOCACHE_S3_BUCKET=cache-bucket-name |
| 32 | + export GOCACHEPROG=go-cache-plugin |
| 33 | + go build ... |
| 34 | +
|
| 35 | + In this mode, you must specify the --cache-dir and --bucket settings. |
| 36 | +
|
| 37 | +------------------------------------------------------------------------ |
| 38 | +## To run the plugin as a standalone service |
| 39 | +
|
| 40 | + Use the "serve" subcommand: |
| 41 | +
|
| 42 | + go-cache-plugin serve \ |
| 43 | + --cache-dir=/tmp/gocache --bucket=$B \ |
| 44 | + --socket /var/run/cache.sock |
| 45 | +
|
| 46 | + You can then use the "connect" subcommand to wire up the toolchain: |
| 47 | +
|
| 48 | + export GOCACHEPROG="go-cache-plugin connect /var/run/cache.sock" |
| 49 | +
|
| 50 | + In this mode, the server must have credentials to access to S3, but the |
| 51 | + toolchain process does not need AWS credentials. |
| 52 | +
|
| 53 | +------------------------------------------------------------------------ |
| 54 | +## Running a Go module and sum database proxy |
| 55 | +
|
| 56 | + With the --modproxy flag, the server will also export an HTTP proxy for the |
| 57 | + public Go module proxy (proxy.golang.org) and sum DB (sum.golang.org) at the |
| 58 | + given address: |
| 59 | +
|
| 60 | + go-cache-plugin serve ... --modproxy=localhost:5970 |
| 61 | +
|
| 62 | + To use the module proxy, set the standard GOPROXY environment variable: |
| 63 | +
|
| 64 | + export GOPROXY=localhost:5970 |
| 65 | + export GOCACHEPROG="go-cache-plugin connect /var/run/cache.sock" |
| 66 | + go build ... |
| 67 | +
|
| 68 | + To use the sum DB proxy, set the GOSUMDB environment variable: |
| 69 | +
|
| 70 | + export GOSUMDB="sum.golang.org http://localhost:5970/sumdb/sum.golang.org" |
| 71 | +
|
| 72 | + See also: https://proxy.golang.org/ |
| 73 | +`, |
| 74 | + }, |
| 75 | + { |
| 76 | + Name: "environment", |
| 77 | + Help: `Environment variables understood by this program. |
| 78 | +
|
| 79 | +To make it easier to configure this tool for multiple workflows, most of the |
| 80 | +settings can be set via environment variables as well as flags. |
| 81 | +
|
| 82 | + -------------------------------------------------------------------- |
| 83 | + Flag (global) Variable Format Default |
| 84 | + -------------------------------------------------------------------- |
| 85 | + --cache-dir GOCACHE_DIR path (required) |
| 86 | + --bucket GOCACHE_S3_BUCKET string (required) |
| 87 | + --region GOCACHE_S3_REGION string based on bucket |
| 88 | + --prefix GOCACHE_KEY_PREFIX string "" |
| 89 | + --min-upload-size GOCACHE_MIN_SIZE int64 0 |
| 90 | + --metrics GOCACHE_METRICS bool false |
| 91 | + --expiry GOCACHE_EXPIRY duration 0 |
| 92 | + -c GOCACHE_CONCURRENCY int runtime.NumCPU |
| 93 | + -u GOCACHE_S3_CONCURRENCY duration runtime.NumCPU |
| 94 | + -v GOCACHE_VERBOSE bool false |
| 95 | + --debug GOCACHE_DEBUG bool false |
| 96 | +
|
| 97 | + -------------------------------------------------------------------- |
| 98 | + Flag (serve) Variable Format Default |
| 99 | + -------------------------------------------------------------------- |
| 100 | + --socket GOCACHE_SOCKET path (required) |
| 101 | + --modproxy GOCACHE_MODPROXY [host]:port "" |
| 102 | + --sumdb GOCACHE_SUMDB host,... "" |
| 103 | +
|
| 104 | +See also "help configure".`, |
| 105 | + }, |
| 106 | +} |
0 commit comments