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

Generate docs from CRD spec #505

Merged
merged 6 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ensure-generate-is-noop: set-image-controller generate bundle
@git restore config/manager/kustomization.yaml
@git diff -s --exit-code api/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code docs/api.md || (echo "Build failed: the api.md file has been changed but the generated api.md file isn't up to date. Run 'make api-docs' and update your PR." && git diff && exit 1)
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved

all: manager
ci: test
Expand Down Expand Up @@ -112,7 +113,7 @@ lint:
golangci-lint run

# Generate code
generate: controller-gen
generate: controller-gen api-docs
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# end-to-tests
Expand All @@ -135,7 +136,7 @@ container:
container-push:
docker push ${IMG}

start-kind:
start-kind:
kind create cluster --config $(KIND_CONFIG)
kind load docker-image local/opentelemetry-operator:e2e

Expand Down Expand Up @@ -232,3 +233,28 @@ bundle-push:
docker push $(BUNDLE_IMG)

tools: ginkgo kustomize controller-gen operator-sdk


api-docs: crdoc kustomize
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ; \
$(KUSTOMIZE) build config/crd -o $$TMP_DIR/crd-output.yaml ;\
$(API_REF_GEN) crdoc --resources $$TMP_DIR/crd-output.yaml --output docs/api.md ;\
}

# Find or download crdoc
crdoc:
ifeq (, $(shell which crdoc))
@{ \
set -e ;\
API_REF_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$API_REF_GEN_TMP_DIR ;\
go mod init tmp ;\
go get fybrik.io/crdoc@v0.5.2 ;\
rm -rf $$API_REF_GEN_TMP_DIR ;\
}
API_REF_GEN=$(GOBIN)/crdoc
else
API_REF_GEN=$(shell which crdoc)
endif
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ The operator manages:

## Documentation

* [OpenTelemetryCollector Custom Resource Specification](./docs/otelcol_cr_spec.md)
* [Instrumentation Custom Resource Specification](./docs/otelinst_cr_spec.md)
* [API docs](./docs/api.md)

## Getting started

Expand Down
Loading