Skip to content

Commit 42cb425

Browse files
Document Dependencies (Azure#3496)
* Create file header and footer * Add documentation to script * Add new target to Taskfile * Add generated documentation file * Address PR feedback
1 parent 7b7d82a commit 42cb425

File tree

5 files changed

+113
-1
lines changed

5 files changed

+113
-1
lines changed

.devcontainer/install-dependencies.sh

+37-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ set -eu
2424
# -s --skip-installed : Skip anything that's already installed
2525
#
2626

27+
#
28+
# This file includes documentation in lines prefixed `#doc#`.
29+
# These lines are extracted by running `task doc:dependencies` from the root folder.
30+
#
31+
# Each depencency should be documented by a single line with the following content:
32+
#
33+
# | <name> | <version> | <details> |
34+
#
35+
# Details should include at minimum a link to the originating website.
36+
# Be sure to use include the `#doc#` prefix on each line.
37+
#
38+
2739
VERBOSE=false
2840
SKIP=false
2941
DEVCONTAINER=false
@@ -82,6 +94,7 @@ fi
8294

8395
# Ensure we have the right version of GO
8496

97+
#doc# | Go | 1.20 | https://golang.org/doc/install #
8598
if ! command -v go > /dev/null 2>&1; then
8699
write-error "Go must be installed manually; see https://golang.org/doc/install"
87100
exit 1
@@ -91,14 +104,15 @@ GOVER=$(go version)
91104
write-info "Go version: ${GOVER[*]}"
92105

93106
GOVERREQUIRED="go1.20.*"
94-
GOVERACTUAL=$(go version | { read _ _ ver _; echo $ver; })
107+
GOVERACTUAL=$(go version | { read _ _ ver _; echo "$ver"; })
95108
if ! [[ "$GOVERACTUAL" =~ $GOVERREQUIRED ]]; then
96109
write-error "Go must be version $GOVERREQUIRED, not $GOVERACTUAL; see : https://golang.org/doc/install"
97110
exit 1
98111
fi
99112

100113
# Ensure we have AZ
101114

115+
#doc# | AZ | latest | https://docs.microsoft.com/en-us/cli/azure/install-azure-cli |
102116
if ! command -v az > /dev/null 2>&1; then
103117
write-error "Azure CLI must be installed manually: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli"
104118
exit 1
@@ -145,25 +159,39 @@ go-install() {
145159
fi
146160
}
147161

162+
#doc# | conversion-gen | v0.28.0 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
148163
go-install conversion-gen k8s.io/code-generator/cmd/[email protected]
164+
165+
#doc# | controller-gen | v0.13.0 | https://book.kubebuilder.io/reference/controller-gen |
149166
go-install controller-gen sigs.k8s.io/controller-tools/cmd/[email protected]
167+
168+
#doc# | kind | v0.20.0 | https://kind.sigs.k8s.io/ |
150169
go-install kind sigs.k8s.io/[email protected]
170+
171+
#doc# | kustomize | v4.5.7 | https://kustomize.io/ |
151172
go-install kustomize sigs.k8s.io/kustomize/kustomize/[email protected]
152173

153174
# for docs site
175+
176+
#doc# | hugo | v0.88.1 | https://gohugo.io/ |
154177
go-install hugo -tags extended github.com/gohugoio/[email protected]
178+
179+
#doc# | htmltest | latest | https://github.com/wjdp/htmltest (but see https://github.com/theunrepentantgeek/htmltest for our custom build )
155180
# Restore this to github.com/wjdp/htmltest@v?? once PR#215 is merged with the feature we need
156181
go-install htmltest github.com/theunrepentantgeek/htmltest@latest
157182

158183
# for api docs
159184
# TODO: Replace this with the new release tag.
160185
# Currently pinned just after a couple of fixes from @theunrepentantgeek
186+
#doc# | gen-crd-api-reference-docs | 11fe95cb | https://github.com/ahmetb/gen-crd-api-reference-docs |
161187
go-install gen-crd-api-reference-docs github.com/ahmetb/gen-crd-api-reference-docs@11fe95cbdcb91e9c25446fc99e6f2cdd8cbeb91a
162188

163189
# Install envtest tooling - ideally version here should match that used in v2/go.mod, but only @latest works
190+
#doc# | setup-envtest | latest | https://book.kubebuilder.io/reference/envtest.html |
164191
go-install setup-envtest sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
165192

166193
# Install golangci-lint
194+
#doc# | golangci-lint | 1.51.2 | https://github.com/golangci/golangci-lint |
167195
write-verbose "Checking for $TOOL_DEST/golangci-lint"
168196
if should-install "$TOOL_DEST/golangci-lint"; then
169197
write-info "Installing golangci-lint"
@@ -173,27 +201,31 @@ if should-install "$TOOL_DEST/golangci-lint"; then
173201
fi
174202

175203
# Install Task
204+
#doc# | Task | v3.31 | https://taskfile.dev/ |
176205
write-verbose "Checking for $TOOL_DEST/go-task"
177206
if should-install "$TOOL_DEST/task"; then
178207
write-info "Installing go-task"
179208
curl -sL "https://github.com/go-task/task/releases/download/v3.31.0/task_linux_amd64.tar.gz" | tar xz -C "$TOOL_DEST" task
180209
fi
181210

182211
# Install Trivy
212+
#doc# | Trivy | v0.37.3 | https://trivy.dev/ |
183213
write-verbose "Checking for $TOOL_DEST/trivy"
184214
if should-install "$TOOL_DEST/trivy"; then
185215
write-info "Installing trivy"
186216
curl -sL "https://github.com/aquasecurity/trivy/releases/download/v0.37.3/trivy_0.37.3_Linux-64bit.tar.gz" | tar xz -C "$TOOL_DEST" trivy
187217
fi
188218

189219
# Install helm
220+
#doc# | Helm | v3.8.0 | https://helm.sh/ |
190221
write-verbose "Checking for $TOOL_DEST/helm"
191222
if should-install "$TOOL_DEST/helm"; then
192223
write-info "Installing helm…"
193224
curl -sL "https://get.helm.sh/helm-v3.8.0-linux-amd64.tar.gz" | tar -C "$TOOL_DEST" --strip-components=1 -xz linux-amd64/helm
194225
fi
195226

196227
# Install yq
228+
#doc# | YQ | v4.13.0 | https://github.com/mikefarah/yq/ |
197229
yq_version=v4.13.0
198230
yq_binary=yq_linux_amd64
199231
write-verbose "Checking for $TOOL_DEST/yq"
@@ -204,6 +236,7 @@ if should-install "$TOOL_DEST/yq"; then
204236
fi
205237

206238
# Install cmctl, used to wait for cert manager installation during some tests cases
239+
#doc# | cmctl | latest | https://cert-manager.io/docs/reference/cmctl |
207240
os=$(go env GOOS)
208241
arch=$(go env GOARCH)
209242
write-verbose "Checking for $TOOL_DEST/cmctl"
@@ -213,6 +246,7 @@ if should-install "$TOOL_DEST/cmctl"; then
213246
fi
214247

215248
write-verbose "Checking for $BUILDX_DEST/docker-buildx"
249+
#doc# | BuildX | v0.11.2 | https://github.com/docker/buildx |
216250
if should-install "$BUILDX_DEST/docker-buildx"; then
217251
write-info "Installing buildx-${os}_${arch} to $BUILDX_DEST"
218252
mkdir -p "$BUILDX_DEST"
@@ -221,13 +255,15 @@ if should-install "$BUILDX_DEST/docker-buildx"; then
221255
fi
222256

223257
# Install azwi
258+
#doc# | AZWI | v1.0.0 | https://github.com/Azure/azure-workload-identity |
224259
write-verbose "Checking for $TOOL_DEST/azwi"
225260
if should-install "$TOOL_DEST/azwi"; then
226261
write-info "Installing azwi…"
227262
curl -sL "https://github.com/Azure/azure-workload-identity/releases/download/v1.0.0/azwi-v1.0.0-${os}-${arch}.tar.gz" | tar xz -C "$TOOL_DEST" azwi
228263
fi
229264

230265
# Ensure tooling for Hugo is available
266+
#doc# | PostCSS | latest | https://postcss.org/ |
231267
write-verbose "Checking for /usr/bin/postcss"
232268
if ! which postcss > /dev/null 2>&1; then
233269
write-info "Installing postcss"

Taskfile.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,13 @@ tasks:
10241024
cmds:
10251025
- "{{.SCRIPTS_ROOT}}/check_frontmatter.py"
10261026

1027+
doc:dependencies:
1028+
desc: Generate documentation for depencencies
1029+
cmds:
1030+
- cp ./docs/v2/dependencies-header.md ./docs/hugo/content/contributing/dependencies.md
1031+
- grep '^[[:space:]]*#doc#' .devcontainer/install-dependencies.sh | sed -e 's/[[:space:]]*#doc# //' | sort -f >> ./docs/hugo/content/contributing/dependencies.md
1032+
- cat ./docs/v2/dependencies-footer.md >> ./docs/hugo/content/contributing/dependencies.md
1033+
10271034
############### Shared targets ###############
10281035

10291036
cleanup-azure-resources:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Developer Dependencies
3+
linktitle: Dependencies
4+
---
5+
Development of Azure Service Operator depends on a number of development tools and libraries that need to be installed.
6+
7+
If you prefer to install those dependencies manually (instead of using the `.devcontainer/install-dependencies.sh` script), here is a list of what's required.
8+
9+
| Dependency | Version | Reference |
10+
|:---------- |:-------:|:--------- |
11+
| AZWI | v1.0.0 | https://github.com/Azure/azure-workload-identity |
12+
| BuildX | v0.11.2 | https://github.com/docker/buildx |
13+
| cmctl | latest | https://cert-manager.io/docs/reference/cmctl |
14+
| controller-gen | v0.13.0 | https://book.kubebuilder.io/reference/controller-gen |
15+
| conversion-gen | v0.28.0 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
16+
| gen-crd-api-reference-docs | 11fe95cb | https://github.com/ahmetb/gen-crd-api-reference-docs |
17+
| golangci-lint | 1.51.2 | https://github.com/golangci/golangci-lint |
18+
| Helm | v3.8.0 | https://helm.sh/ |
19+
| htmltest | latest | https://github.com/wjdp/htmltest (but see https://github.com/theunrepentantgeek/htmltest for our custom build )
20+
| hugo | v0.88.1 | https://gohugo.io/ |
21+
| kind | v0.20.0 | https://kind.sigs.k8s.io/ |
22+
| kustomize | v4.5.7 | https://kustomize.io/ |
23+
| PostCSS | latest | https://postcss.org/ |
24+
| setup-envtest | latest | https://book.kubebuilder.io/reference/envtest.html |
25+
| Task | v3.31 | https://taskfile.dev/ |
26+
| Trivy | v0.37.3 | https://trivy.dev/ |
27+
| YQ | v4.13.0 | https://github.com/mikefarah/yq/ |
28+
29+
Dependencies are listed alphabetically. Refer to `install-dependencies.sh` for a recommended order of installation.
30+
31+
To update this file:
32+
33+
* Modify the file header content in `docs/v2/dependencies-header.md`;
34+
* Modify the file footer in `docs/v2/dependencies-footer.md`; or
35+
* Modify the dependencies installed by `.devcontainer/install-dependencies.sh`.
36+
37+
Regenerate the file using task:
38+
39+
``` bash
40+
$ task doc:dependencies
41+
```
42+
43+
Finally, submit the update as a PR.

docs/v2/dependencies-footer.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Dependencies are listed alphabetically. Refer to `install-dependencies.sh` for a recommended order of installation.
3+
4+
To update this file:
5+
6+
* Modify the file header content in `docs/v2/dependencies-header.md`;
7+
* Modify the file footer in `docs/v2/dependencies-footer.md`; or
8+
* Modify the dependencies installed by `.devcontainer/install-dependencies.sh`.
9+
10+
Regenerate the file using task:
11+
12+
``` bash
13+
$ task doc:dependencies
14+
```
15+
16+
Finally, submit the update as a PR.

docs/v2/dependencies-header.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Developer Dependencies
3+
linktitle: Dependencies
4+
---
5+
Development of Azure Service Operator depends on a number of development tools and libraries that need to be installed.
6+
7+
If you prefer to install those dependencies manually (instead of using the `.devcontainer/install-dependencies.sh` script), here is a list of what's required.
8+
9+
| Dependency | Version | Reference |
10+
|:---------- |:-------:|:--------- |

0 commit comments

Comments
 (0)