88
99type 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.
1114func 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.
4752func 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".
5562func 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.
6270func 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.
7787func 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.
103114func 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.
137150func 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".
145160func WithPlaceholder (value string ) fieldOption {
146161 return func (o SchemaField ) SchemaField {
147162 o .ConnectorConfig .Placeholder = value
0 commit comments