Skip to content

Commit

Permalink
Add docs for the go module generator.
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed May 1, 2024
1 parent 92bcfa2 commit f80b5a9
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion website/docs/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For all source types, you can specify the following top-level configuration:
- `path`: The path to extract from the source type
- `includes`: A list of glob patterns to include from the source
- `excludes`: A list of glob patterns to exclude from the source
- `generate`: See [Generators](#Generators)

The below example uses a [`context`](#build-context) source type.
The root of the source is the `path/in/source` directory.
Expand Down Expand Up @@ -288,10 +289,41 @@ Build args can be specified as well as `args` which is a map of key value pairs.

Build sources are considered to be "directory" sources.

## Generators

Generators are used to generate a source from another source.
Currently the only generator supported is `gomod`.

### Gomod

The `gomod` generator manages a single go module cache for all sources that
specify it in the spec. It is expected that the build dependencies include a
go toolchain suitable for fetching go module dependencies.

Adding a gomod generator to 1 or more sources causes the following to occur automatically:

1. Fetch all go module dependencies for *all* sources in the spec that specifiy the generator
2. Keeps a single go module cache directory for all go module deps.
3. Adds the go module cache directory a source which gets included in source packages like a normal source.
4. Adds the `GOMODCACHE` environment variable to the build environment.

```yaml
sources:
md2man:
git:
url: https://github.com/cpuguy83/go-md2man.git
commit: v2.1.0
generate:
subpath: "" # path inside the source to use as the root for the generator
gomod: {} # Generates a go module cache to cache dependencies
```

`gomod` currently does not have any options but may in the future.

## Advanced Source Configurations

You can see more advanced configurations in our [test fixtures](https://github.com/Azure/dalec/tree/main/test/fixtures).
These are in here to test lots of different edge cases and are only mentioned to provide examples of what might be possible
when these simple configurations are not enough.
The examples in that directory are not exhaustive and are not guaranteed to work in all cases or with all inputs and are
there strictly for testing purposes.
there strictly for testing purposes.

0 comments on commit f80b5a9

Please sign in to comment.