Skip to content

Commit b515557

Browse files
authored
Merge pull request #1165 from keynslug/doc/refine-v2-crd
chore: refine descriptions of CRD API structures
2 parents ca556a4 + 0649aa1 commit b515557

File tree

8 files changed

+722
-257
lines changed

8 files changed

+722
-257
lines changed

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ build: manifests generate fmt vet ## Build manager binary.
9797
run: manifests generate fmt vet ## Run a controller from your host.
9898
go run ./cmd/main.go
9999

100+
.PHONY: doc
101+
doc: crd-ref-docs manifests doc-crd-v2 ## Generate documentation for the CRDs.
102+
103+
.PHONY: doc-crd-v2
104+
doc-crd-v2: ## Generate documentation for the `apps.emqx.io/v2` CRD.
105+
$(CRD_REF_DOCS) \
106+
--source-path=api/v2 \
107+
--config=crd-ref-docs-config.yaml \
108+
--output-path=docs/en_US/reference/v2-reference.md \
109+
--renderer=markdown
110+
100111
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
101112
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
102113
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
@@ -178,12 +189,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
178189
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
179190
ENVTEST ?= $(LOCALBIN)/setup-envtest
180191
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
192+
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
181193

182194
## Tool Versions
183195
KUSTOMIZE_VERSION ?= v5.5.0
184196
CONTROLLER_TOOLS_VERSION ?= v0.18.0
185197
ENVTEST_VERSION ?= release-0.19
186198
GOLANGCI_LINT_VERSION ?= v1.64.8
199+
CRD_REF_DOCS_VERSION ?= latest
187200

188201
.PHONY: kustomize
189202
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -205,6 +218,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
205218
$(GOLANGCI_LINT): $(LOCALBIN)
206219
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
207220

221+
.PHONY: crd-ref-docs
222+
crd-ref-docs: $(CRD_REF_DOCS) ## Download crd-ref-docs locally if necessary.
223+
$(CRD_REF_DOCS): $(LOCALBIN)
224+
$(call go-install-tool,$(CRD_REF_DOCS),github.com/elastic/crd-ref-docs,$(CRD_REF_DOCS_VERSION))
225+
208226
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
209227
# $1 - target path with name of binary
210228
# $2 - package url which can be installed

api/v2/emqx_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ import (
2727
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.status==\"True\")].type"
2828
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
2929

30-
// EMQX is the Schema for the emqxes API.
30+
// Custom Resource representing an EMQX cluster.
3131
type EMQX struct {
3232
metav1.TypeMeta `json:",inline"`
3333
metav1.ObjectMeta `json:"metadata,omitempty"`
3434

35-
Spec EMQXSpec `json:"spec,omitempty"`
35+
// Specification of the desired state of the EMQX cluster.
36+
Spec EMQXSpec `json:"spec,omitempty"`
37+
// Current status of the EMQX cluster.
3638
Status EMQXStatus `json:"status,omitempty"`
3739
}
3840

3941
// +kubebuilder:object:root=true
40-
41-
// EMQXList contains a list of EMQX.
4242
type EMQXList struct {
4343
metav1.TypeMeta `json:",inline"`
4444
metav1.ListMeta `json:"metadata,omitempty"`

api/v2/emqx_types_spec.go

Lines changed: 76 additions & 81 deletions
Large diffs are not rendered by default.

api/v2/emqx_types_status.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,25 @@ import (
2424

2525
// EMQXStatus defines the observed state of EMQX
2626
type EMQXStatus struct {
27-
// Represents the latest available observations of a EMQX Custom Resource current state.
27+
// Conditions representing the current status of the EMQX Custom Resource.
2828
// +listType=map
2929
// +listMapKey=type
3030
Conditions []metav1.Condition `json:"conditions,omitempty"`
3131

32-
CoreNodes []EMQXNode `json:"coreNodes,omitempty"`
32+
// Status of each core node in the cluster.
33+
CoreNodes []EMQXNode `json:"coreNodes,omitempty"`
34+
// Summary status of the set of core nodes.
3335
CoreNodesStatus EMQXNodesStatus `json:"coreNodesStatus,omitempty"`
3436

35-
ReplicantNodes []EMQXNode `json:"replicantNodes,omitempty"`
37+
// Status of each replicant node in the cluster.
38+
ReplicantNodes []EMQXNode `json:"replicantNodes,omitempty"`
39+
// Summary status of the set of replicant nodes.
3640
ReplicantNodesStatus EMQXNodesStatus `json:"replicantNodesStatus,omitempty"`
3741

42+
// Status of active node evacuations in the cluster.
3843
NodeEvacuationsStatus []NodeEvacuationStatus `json:"nodeEvacuationsStatus,omitempty"`
39-
DSReplication DSReplicationStatus `json:"dsReplication,omitempty"`
44+
// Status of EMQX Durable Storage replication.
45+
DSReplication DSReplicationStatus `json:"dsReplication,omitempty"`
4046
}
4147

4248
type NodeEvacuationStatus struct {
@@ -48,24 +54,31 @@ type NodeEvacuationStatus struct {
4854
State string `json:"state,omitempty"`
4955
// Session recipients
5056
// +kubebuilder:example={"[email protected]", "[email protected]"}
51-
SessionRecipients []string `json:"sessionRecipients,omitempty"`
52-
SessionEvictionRate int32 `json:"sessionEvictionRate,omitempty"`
53-
ConnectionEvictionRate int32 `json:"connectionEvictionRate,omitempty"`
57+
SessionRecipients []string `json:"sessionRecipients,omitempty"`
58+
// Session eviction rate, in sessions per second.
59+
SessionEvictionRate int32 `json:"sessionEvictionRate,omitempty"`
60+
// Connection eviction rate, in connections per second.
61+
ConnectionEvictionRate int32 `json:"connectionEvictionRate,omitempty"`
5462
// Initial number of sessions on this node
5563
InitialSessions int32 `json:"initialSessions,omitempty"`
5664
// Initial number of connections to this node
5765
InitialConnections int32 `json:"initialConnections,omitempty"`
5866
}
5967

6068
type EMQXNodesStatus struct {
61-
Replicas int32 `json:"replicas,omitempty"`
69+
// Total number of replicas.
70+
Replicas int32 `json:"replicas,omitempty"`
71+
// Number of ready replicas.
6272
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
63-
73+
// Current revision of the respective core or replicant set.
6474
CurrentRevision string `json:"currentRevision,omitempty"`
65-
CurrentReplicas int32 `json:"currentReplicas,omitempty"`
66-
75+
// Number of replicas running current revision.
76+
CurrentReplicas int32 `json:"currentReplicas,omitempty"`
77+
// Update revision of the respective core or replicant set.
78+
// When different from the current revision, the set is being updated.
6779
UpdateRevision string `json:"updateRevision,omitempty"`
68-
UpdateReplicas int32 `json:"updateReplicas,omitempty"`
80+
// Number of replicas running update revision.
81+
UpdateReplicas int32 `json:"updateReplicas,omitempty"`
6982

7083
CollisionCount *int32 `json:"collisionCount,omitempty"`
7184
}

0 commit comments

Comments
 (0)