Skip to content

Commit

Permalink
Merge pull request #18 from erbesharat/docs/v2
Browse files Browse the repository at this point in the history
[documentation]: Update README and add configuration docs
  • Loading branch information
stp-ip committed Mar 22, 2020
2 parents 87e3624 + 73a9542 commit 8e62449
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 9 deletions.
13 changes: 10 additions & 3 deletions .seed-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ vision:

readme:
usageExample: |
Note: The `master` branch is using [Caddy v2](https://caddyserver.com), if you want to use Gomods with previous Caddy versions, check the caddy-v1 branch.
Gomods uses Go tools in the background for fetching the modules so there needs to be an installed version of Go on your machine.
For installing Gomods run the following command:
```
go get go.okkur.org/gomods/cmd/gomods@caddy-v1
go get go.okkur.org/gomods/cmd/gomods
```
Then you should create a config file like this example:
Expand All @@ -38,6 +40,7 @@ readme:
gomods
}
```
The example above uses the default values for Go binary and number of parallel workers.
To customize these values add these fields to your config file:
```
Expand All @@ -57,6 +60,7 @@ readme:
}
}
```
Just like `gomods` itself, cache also uses its default values when not provided.
You can specify fields like `type` and `path` to customize caching:
```
Expand All @@ -70,9 +74,12 @@ readme:
}
```
To run Gomods use the following command:
For more information about the configuration options and the JSON config
example, check the [Configuration](/docs/configuration.md) page.
To run Gomods run the following command in the same directory that the config file is located:
```
$ gomods -conf PATH_TO_CONFIG
$ gomods start
```
contributionLinks:
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Gomods

**This version supports Caddy v1 only.**
**For the latest Caddy support take a look at the latest version and code.**

Caddy plugin that provides a caching Go modules proxy with your own domain.

[![state](https://img.shields.io/badge/state-beta-blue.svg)]() [![release](https://img.shields.io/github/release/okkur/gomods.svg)](https://gomods.okkur.org/releases) [![license](https://img.shields.io/github/license/okkur/gomods.svg)](LICENSE)
Expand All @@ -14,11 +11,13 @@ It supports all the hosting services and VCS` that are supported by Go tools. It
and parallel workers to fetch and store Go modules.

## Using Gomods
Note: The `master` branch is using [Caddy v2](https://caddyserver.com), if you want to use Gomods with previous Caddy versions, check the caddy-v1 branch.

Gomods uses Go tools in the background for fetching the modules so there needs to be an installed version of Go on your machine.

For installing Gomods run the following command:
```
go get go.okkur.org/gomods/cmd/gomods@caddy-v1
go get go.okkur.org/gomods/cmd/gomods
```

Then you should create a config file like this example:
Expand All @@ -27,6 +26,7 @@ gomods.test {
gomods
}
```

The example above uses the default values for Go binary and number of parallel workers.
To customize these values add these fields to your config file:
```
Expand All @@ -46,6 +46,7 @@ gomods.test {
}
}
```

Just like `gomods` itself, cache also uses its default values when not provided.
You can specify fields like `type` and `path` to customize caching:
```
Expand All @@ -59,9 +60,12 @@ gomods.test {
}
```

To run Gomods use the following command:
For more information about the configuration options and the JSON config
example, check the [Configuration](/docs/configuration.md) page.

To run Gomods run the following command in the same directory that the config file is located:
```
$ gomods -conf PATH_TO_CONFIG
$ gomods start
```


Expand Down
89 changes: 89 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Configuration

Gomods has a set of default values for the config options and you can use it by
only adding the plugin name inside your config file.

Here is a example in Caddyfile format:

```
gomods.test {
gomods
}
```

## Config Options

General options:

- `gobinary`: _string_ - Path to the Go binary (Default: `/usr/bin/go`)
- `workers`: _integer_ - Number of workers for fetching the modules (Default: `1`)
- `cache`: _object_ - Cache configuration object

Cache options:

- `type`: _string_ - Cache storage type (Default: `tmp`, Options: [`local`, `tmp`])
- `path`: _string_ - Cache storage path (Default: `/tmp`)

## Examples

Caddyfile Example:

```
gomods.test {
gomods {
gobinary /my/go/binary
workers 5
cache {
type local
path /my/cache/path
}
}
}
```

JSON Example:

```json
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [":443"],
"routes": [
{
"match": [
{
"host": ["gomods.test"]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"Config": {
"cache": {
"path": "/my/cache/path",
"type": "local"
},
"gobinary": "/my/go/binary",
"workers": 5
},
"handler": "gomods"
}
]
}
]
}
]
}
]
}
}
}
}
}
```

0 comments on commit 8e62449

Please sign in to comment.