Skip to content

Commit 33f5f58

Browse files
authored
Merge pull request #2897 from redpanda-data/redpanda-config
Add a redpanda page to the generated docs
2 parents d124570 + 188b874 commit 33f5f58

File tree

6 files changed

+636
-19
lines changed

6 files changed

+636
-19
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Changelog
33

44
All notable changes to this project will be documented in this file.
55

6-
## 4.37.0 - TBD
6+
## 4.37.0 - 2024-09-26
77

88
### Added
99

cmd/tools/docs_gen/main.go

+41-13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"github.com/redpanda-data/benthos/v4/public/bloblang"
2828
"github.com/redpanda-data/benthos/v4/public/service"
2929

30+
"github.com/redpanda-data/connect/v4/public/schema"
31+
3032
_ "github.com/redpanda-data/connect/v4/public/components/all"
3133

3234
_ "embed"
@@ -50,6 +52,9 @@ var templateHTTPRaw string
5052
//go:embed templates/logger.adoc.tmpl
5153
var templateLoggerRaw string
5254

55+
//go:embed templates/redpanda.adoc.tmpl
56+
var templateRedpandaRaw string
57+
5358
//go:embed templates/tests.adoc.tmpl
5459
var templateTestsRaw string
5560

@@ -62,6 +67,7 @@ var (
6267
templatePlugin *template.Template
6368
templateHTTP *template.Template
6469
templateLogger *template.Template
70+
templateRedpanda *template.Template
6571
templateTests *template.Template
6672
templateTemplates *template.Template
6773
)
@@ -72,6 +78,7 @@ func init() {
7278
templatePlugin = template.Must(template.New("plugin").Parse(templatePluginFieldsRaw + templatePluginRaw))
7379
templateHTTP = template.Must(template.New("http").Parse(templatePluginFieldsRaw + templateHTTPRaw))
7480
templateLogger = template.Must(template.New("logger").Parse(templatePluginFieldsRaw + templateLoggerRaw))
81+
templateRedpanda = template.Must(template.New("redpanda").Parse(templatePluginFieldsRaw + templateRedpandaRaw))
7582
templateTests = template.Must(template.New("tests").Parse(templatePluginFieldsRaw + templateTestsRaw))
7683
templateTemplates = template.Must(template.New("templates").Parse(templatePluginFieldsRaw + templateTemplatesRaw))
7784
}
@@ -88,20 +95,24 @@ func create(t, path string, resBytes []byte) {
8895
fmt.Printf("Documentation for '%v' has changed, updating: %v\n", t, path)
8996
}
9097

98+
func getSchema() *service.ConfigSchema {
99+
return schema.Standard("", "")
100+
}
101+
91102
func main() {
92103
docsDir := "./docs/modules/components/pages"
93104
flag.StringVar(&docsDir, "dir", docsDir, "The directory to write docs to")
94105
flag.Parse()
95106

96-
service.GlobalEnvironment().WalkInputs(viewForDir(path.Join(docsDir, "./inputs")))
97-
service.GlobalEnvironment().WalkBuffers(viewForDir(path.Join(docsDir, "./buffers")))
98-
service.GlobalEnvironment().WalkCaches(viewForDir(path.Join(docsDir, "./caches")))
99-
service.GlobalEnvironment().WalkMetrics(viewForDir(path.Join(docsDir, "./metrics")))
100-
service.GlobalEnvironment().WalkOutputs(viewForDir(path.Join(docsDir, "./outputs")))
101-
service.GlobalEnvironment().WalkProcessors(viewForDir(path.Join(docsDir, "./processors")))
102-
service.GlobalEnvironment().WalkRateLimits(viewForDir(path.Join(docsDir, "./rate_limits")))
103-
service.GlobalEnvironment().WalkTracers(viewForDir(path.Join(docsDir, "./tracers")))
104-
service.GlobalEnvironment().WalkScanners(viewForDir(path.Join(docsDir, "./scanners")))
107+
getSchema().Environment().WalkInputs(viewForDir(path.Join(docsDir, "./inputs")))
108+
getSchema().Environment().WalkBuffers(viewForDir(path.Join(docsDir, "./buffers")))
109+
getSchema().Environment().WalkCaches(viewForDir(path.Join(docsDir, "./caches")))
110+
getSchema().Environment().WalkMetrics(viewForDir(path.Join(docsDir, "./metrics")))
111+
getSchema().Environment().WalkOutputs(viewForDir(path.Join(docsDir, "./outputs")))
112+
getSchema().Environment().WalkProcessors(viewForDir(path.Join(docsDir, "./processors")))
113+
getSchema().Environment().WalkRateLimits(viewForDir(path.Join(docsDir, "./rate_limits")))
114+
getSchema().Environment().WalkTracers(viewForDir(path.Join(docsDir, "./tracers")))
115+
getSchema().Environment().WalkScanners(viewForDir(path.Join(docsDir, "./scanners")))
105116

106117
// Bloblang stuff
107118
doBloblangMethods(docsDir)
@@ -116,6 +127,9 @@ func main() {
116127
// Logger docs
117128
doLogger(docsDir)
118129

130+
// Redpanda docs
131+
doRedpanda(docsDir)
132+
119133
// Template docs
120134
doTemplates(docsDir)
121135
}
@@ -284,7 +298,7 @@ func doBloblangMethods(dir string) {
284298
}
285299

286300
func doTestDocs(dir string) {
287-
data, err := service.GlobalEnvironment().FullConfigSchema("", "").TemplateData()
301+
data, err := getSchema().TemplateData()
288302
if err != nil {
289303
panic(fmt.Sprintf("Failed to prepare tests docs: %v", err))
290304
}
@@ -306,7 +320,7 @@ func doTestDocs(dir string) {
306320
}
307321

308322
func doHTTP(dir string) {
309-
data, err := service.GlobalEnvironment().FullConfigSchema("", "").TemplateData("http")
323+
data, err := getSchema().TemplateData("http")
310324
if err != nil {
311325
panic(fmt.Sprintf("Failed to prepare http docs: %v", err))
312326
}
@@ -320,7 +334,7 @@ func doHTTP(dir string) {
320334
}
321335

322336
func doLogger(dir string) {
323-
data, err := service.GlobalEnvironment().FullConfigSchema("", "").TemplateData("logger")
337+
data, err := getSchema().TemplateData("logger")
324338
if err != nil {
325339
panic(fmt.Sprintf("Failed to prepare logger docs: %v", err))
326340
}
@@ -333,8 +347,22 @@ func doLogger(dir string) {
333347
create("logger docs", filepath.Join(dir, "logger", "about.adoc"), buf.Bytes())
334348
}
335349

350+
func doRedpanda(dir string) {
351+
data, err := getSchema().TemplateData("redpanda")
352+
if err != nil {
353+
panic(fmt.Sprintf("Failed to prepare redpanda docs: %v", err))
354+
}
355+
356+
var buf bytes.Buffer
357+
if err := templateRedpanda.Execute(&buf, data); err != nil {
358+
panic(fmt.Sprintf("Failed to generate redpanda docs: %v", err))
359+
}
360+
361+
create("redpanda docs", filepath.Join(dir, "redpanda", "about.adoc"), buf.Bytes())
362+
}
363+
336364
func doTemplates(dir string) {
337-
data, err := service.GlobalEnvironment().TemplateSchema("", "").TemplateData()
365+
data, err := getSchema().Environment().TemplateSchema("", "").TemplateData()
338366
if err != nil {
339367
panic(fmt.Sprintf("Failed to prepare template docs: %v", err))
340368
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
=
2+
3+
4+
////
5+
THIS FILE IS AUTOGENERATED!
6+
7+
To make changes please edit the contents of:
8+
9+
https://github.com/redpanda-data/connect/tree/main/cmd/tools/docs_gen/templates/redpanda.adoc.tmpl
10+
////
11+
12+
// © 2024 Redpanda Data Inc.
13+
14+
As well as the default xref:components:logger/about.adoc[logger], you can configure Redpanda Connect to send logs to a topic in a Redpanda cluster.
15+
16+
The configuration for this server lives under the `redpanda` namespace, with the following default values:
17+
18+
{{if eq .CommonConfigYAML .AdvancedConfigYAML -}}
19+
```yaml
20+
# Config fields, showing default values
21+
{{.CommonConfigYAML -}}
22+
```
23+
{{else}}
24+
25+
[tabs]
26+
======
27+
Common::
28+
+
29+
--
30+
31+
```yaml
32+
# Common config fields, showing default values
33+
{{.CommonConfigYAML -}}
34+
```
35+
36+
--
37+
Advanced::
38+
+
39+
--
40+
41+
```yaml
42+
# All config fields, showing default values
43+
{{.AdvancedConfigYAML -}}
44+
```
45+
--
46+
======
47+
{{end -}}
48+
49+
== Fields
50+
51+
The schema of the `redpanda` section is as follows:
52+
53+
{{template "field_docs" . -}}

docs/modules/components/pages/logger/about.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ logger:
2828
format: logfmt
2929
add_timestamp: false
3030
static_fields:
31-
'@service': benthos
31+
'@service': redpanda-connect
3232
```
3333
3434
--
@@ -46,7 +46,7 @@ logger:
4646
timestamp_name: time
4747
message_name: msg
4848
static_fields:
49-
'@service': benthos
49+
'@service': redpanda-connect
5050
file:
5151
path: ""
5252
rotate: false
@@ -136,7 +136,7 @@ A map of key/value pairs to add to each structured log.
136136
137137
*Type*: `object`
138138
139-
*Default*: `{"@service":"benthos"}`
139+
*Default*: `{"@service":"redpanda-connect"}`
140140
141141
=== `file`
142142

0 commit comments

Comments
 (0)