Skip to content

Commit 042f366

Browse files
authored
Merge pull request #63 from fluxcd/docs/api-ref
Generate API documentation
2 parents eb5ed4f + 7e647a6 commit 042f366

File tree

11 files changed

+1349
-5
lines changed

11 files changed

+1349
-5
lines changed

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Image URL to use all building/pushing image targets
32
IMG ?= fluxcd/source-controller:latest
43
# Produce CRDs that work back to Kubernetes 1.13
@@ -14,7 +13,7 @@ endif
1413
all: manager
1514

1615
# Run tests
17-
test: generate fmt vet manifests
16+
test: generate fmt vet manifests api-docs
1817
go test ./... -coverprofile cover.out
1918

2019
# Build manager binary
@@ -49,6 +48,10 @@ dev-deploy: manifests
4948
manifests: controller-gen
5049
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases
5150

51+
# Generate API reference documentation
52+
api-docs: gen-crd-api-reference-docs
53+
$(API_REF_GEN) -api-dir=./api/v1alpha1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md
54+
5255
# Run go fmt against code
5356
fmt:
5457
go fmt ./...
@@ -84,3 +87,19 @@ CONTROLLER_GEN=$(GOBIN)/controller-gen
8487
else
8588
CONTROLLER_GEN=$(shell which controller-gen)
8689
endif
90+
91+
# Find or download gen-crd-api-reference-docs
92+
gen-crd-api-reference-docs:
93+
ifeq (, $(shell which gen-crd-api-reference-docs))
94+
@{ \
95+
set -e ;\
96+
API_REF_GEN_TMP_DIR=$$(mktemp -d) ;\
97+
cd $$API_REF_GEN_TMP_DIR ;\
98+
go mod init tmp ;\
99+
go get github.com/ahmetb/[email protected] ;\
100+
rm -rf $$API_REF_GEN_TMP_DIR ;\
101+
}
102+
API_REF_GEN=$(GOBIN)/gen-crd-api-reference-docs
103+
else
104+
API_REF_GEN=$(shell which gen-crd-api-reference-docs)
105+
endif

api/v1alpha1/doc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2020 The Flux CD contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha1 contains API Schema definitions for the source v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=source.fluxcd.io
20+
package v1alpha1

api/v1alpha1/gitrepository_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ func (in *GitRepository) GetInterval() metav1.Duration {
199199
return in.Spec.Interval
200200
}
201201

202+
// +genclient
203+
// +genclient:Namespaced
202204
// +kubebuilder:object:root=true
203205
// +kubebuilder:subresource:status
204206
// +kubebuilder:printcolumn:name="URL",type=string,JSONPath=`.spec.url`

api/v1alpha1/groupversion_info.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the source v1alpha1 API group
18-
// +kubebuilder:object:generate=true
19-
// +groupName=source.fluxcd.io
2017
package v1alpha1
2118

2219
import (

api/v1alpha1/helmchart_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ func (in *HelmChart) GetInterval() metav1.Duration {
147147
return in.Spec.Interval
148148
}
149149

150+
// +genclient
151+
// +genclient:Namespaced
150152
// +kubebuilder:object:root=true
151153
// +kubebuilder:subresource:status
152154
// +kubebuilder:printcolumn:name="Name",type=string,JSONPath=`.spec.name`

api/v1alpha1/helmrepository_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ func (in *HelmRepository) GetInterval() metav1.Duration {
146146
return in.Spec.Interval
147147
}
148148

149+
// +genclient
150+
// +genclient:Namespaced
149151
// +kubebuilder:object:root=true
150152
// +kubebuilder:subresource:status
151153
// +kubebuilder:printcolumn:name="URL",type=string,JSONPath=`.spec.url`

0 commit comments

Comments
 (0)