Skip to content

Commit 502ddba

Browse files
committed
Add some descriptions to some field methods.
1 parent 24de2f6 commit 502ddba

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/field/field_options.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88

99
type fieldOption func(SchemaField) SchemaField
1010

11+
// WithRequired sets whether the field is required or not.
12+
// If a required field is not set, the connector will error on startup.
13+
// In the GUI, empty required fields will fail form validation.
1114
func WithRequired(required bool) fieldOption {
1215
return func(o SchemaField) SchemaField {
1316
o.Required = required
@@ -44,6 +47,8 @@ func WithRequired(required bool) fieldOption {
4447
}
4548
}
4649

50+
// WithDescription sets the description for the field.
51+
// The description is shown in the GUI config and CLI help.
4752
func WithDescription(description string) fieldOption {
4853
return func(o SchemaField) SchemaField {
4954
o.Description = description
@@ -52,13 +57,16 @@ func WithDescription(description string) fieldOption {
5257
}
5358
}
5459

60+
// WithDisplayName sets the display name for the field.
61+
// The display name is only shown in the GUI, and should be a human-readable name such as "Otel Collector Endpoint".
5562
func WithDisplayName(displayName string) fieldOption {
5663
return func(o SchemaField) SchemaField {
5764
o.ConnectorConfig.DisplayName = displayName
5865
return o
5966
}
6067
}
6168

69+
// WithDefaultValue sets the default value for the field.
6270
func WithDefaultValue(value any) fieldOption {
6371
return func(o SchemaField) SchemaField {
6472
o.DefaultValue = value
@@ -74,6 +82,8 @@ func WithDefaultValueFunc(f func() any) fieldOption {
7482
}
7583
}
7684

85+
// WithHidden sets whether the field is hidden or not.
86+
// Hidden fields will not be shown in the GUI config or CLI help.
7787
func WithHidden(hidden bool) fieldOption {
7888
return func(o SchemaField) SchemaField {
7989
o.SyncerConfig.Hidden = hidden
@@ -100,6 +110,7 @@ const (
100110
ExportTargetCLIOnly ExportTarget = "cli"
101111
)
102112

113+
// WithExportTarget sets the export target for the field. See ExportTarget for more details.
103114
func WithExportTarget(target ExportTarget) fieldOption {
104115
return func(o SchemaField) SchemaField {
105116
if o.ExportTarget != ExportTargetGUI && target != o.ExportTarget {
@@ -134,6 +145,8 @@ func WithPersistent(value bool) fieldOption {
134145
}
135146
}
136147

148+
// WithIsSecret sets the field to be secret, causing the values to be obscured in the GUI.
149+
// This is meant for fields that contain sensitive information, such as passwords or API keys.
137150
func WithIsSecret(value bool) fieldOption {
138151
return func(o SchemaField) SchemaField {
139152
o.Secret = value
@@ -142,6 +155,8 @@ func WithIsSecret(value bool) fieldOption {
142155
}
143156
}
144157

158+
// WithPlaceholder sets the placeholder value for the field.
159+
// The placeholder is only shown in the GUI, and should be an example value such as "my-password" or "my-api-key".
145160
func WithPlaceholder(value string) fieldOption {
146161
return func(o SchemaField) SchemaField {
147162
o.ConnectorConfig.Placeholder = value

0 commit comments

Comments
 (0)