Skip to content

Commit 6a4466a

Browse files
authored
support function with replace sink and source (#823)
* support function with replace sink and source * fix spec * address type changes * fix test * add entry class and instance path
1 parent c3e95f9 commit 6a4466a

21 files changed

+815
-43
lines changed

api/compute/v1alpha1/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ type JavaRuntime struct {
247247
ExtraDependenciesDir string `json:"extraDependenciesDir,omitempty"`
248248
Log *RuntimeLogConfig `json:"log,omitempty"`
249249
JavaOpts []string `json:"javaOpts,omitempty"`
250+
InstancePath *string `json:"instancePath,omitempty"`
251+
EntryClass *string `json:"entryClass,omitempty"`
250252
}
251253

252254
// PythonRuntime contains the python runtime configs

api/compute/v1alpha1/function_types.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ type FunctionSpec struct {
6262
FilebeatImage string `json:"filebeatImage,omitempty"`
6363
// +kubebuilder:validation:Optional
6464
// +kubebuilder:pruning:PreserveUnknownFields
65-
FuncConfig *Config `json:"funcConfig,omitempty"`
65+
FuncConfig *Config `json:"funcConfig,omitempty"`
66+
// +kubebuilder:validation:Optional
67+
SourceConfig *SourceConnectorSpec `json:"sourceConfig,omitempty"`
68+
// +kubebuilder:validation:Optional
69+
SinkConfig *SinkConnectorSpec `json:"sinkConfig,omitempty"`
6670
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
6771
SecretsMap map[string]SecretRef `json:"secretsMap,omitempty"`
6872
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
@@ -152,6 +156,44 @@ type FunctionList struct {
152156
Items []Function `json:"items"`
153157
}
154158

159+
// SourceConnectorSpec describes configurable fields when a function overrides its source implementation.
160+
type SourceConnectorSpec struct {
161+
// Archive points to a nar archive containing the connector. It can reference built-in connectors using the
162+
// builtin:// scheme.
163+
// +kubebuilder:validation:Optional
164+
SourceType string `json:"sourceType,omitempty"` // refer to `--source-type` as builtin connector
165+
// Builtin holds the resolved name of a built-in source connector.
166+
// +kubebuilder:validation:Optional
167+
BatchSourceConfig *BatchSourceConfig `json:"batchSourceConfig,omitempty"`
168+
// ClassName is the fully qualified source implementation class.
169+
// +kubebuilder:validation:Optional
170+
ClassName string `json:"className,omitempty"`
171+
// TypeClassName overrides the expected message type.
172+
// +kubebuilder:validation:Optional
173+
TypeClassName string `json:"typeClassName,omitempty"`
174+
// Configs contains connector specific options.
175+
// +kubebuilder:validation:Optional
176+
// +kubebuilder:pruning:PreserveUnknownFields
177+
Configs *Config `json:"configs,omitempty"`
178+
}
179+
180+
// SinkConnectorSpec describes configurable fields when a function overrides its sink implementation.
181+
type SinkConnectorSpec struct {
182+
// SinkType refers to the built-in sink identifier when using connectors packaged with Pulsar.
183+
// +kubebuilder:validation:Optional
184+
SinkType string `json:"sinkType,omitempty"`
185+
// ClassName is the fully qualified sink implementation class.
186+
// +kubebuilder:validation:Optional
187+
ClassName string `json:"className,omitempty"`
188+
// TypeClassName overrides the message type for the sink.
189+
// +kubebuilder:validation:Optional
190+
TypeClassName string `json:"typeClassName,omitempty"`
191+
// Configs contains connector specific options.
192+
// +kubebuilder:validation:Optional
193+
// +kubebuilder:pruning:PreserveUnknownFields
194+
Configs *Config `json:"configs,omitempty"`
195+
}
196+
155197
func init() {
156198
SchemeBuilder.Register(&Function{}, &FunctionList{})
157199
}

api/compute/v1alpha1/zz_generated.deepcopy.go

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7590,8 +7590,21 @@ spec:
75907590
showPreciseParallelism:
75917591
type: boolean
75927592
sinkConfig:
7593+
properties:
7594+
archive:
7595+
type: string
7596+
builtin:
7597+
type: string
7598+
className:
7599+
type: string
7600+
configs:
7601+
additionalProperties: {}
7602+
type: object
7603+
sinkType:
7604+
type: string
7605+
typeClassName:
7606+
type: string
75937607
type: object
7594-
x-kubernetes-preserve-unknown-fields: true
75957608
sinkType:
75967609
type: string
75977610
statefulConfig:
@@ -11246,8 +11259,19 @@ spec:
1124611259
showPreciseParallelism:
1124711260
type: boolean
1124811261
sourceConfig:
11262+
properties:
11263+
archive:
11264+
type: string
11265+
builtin:
11266+
type: string
11267+
className:
11268+
type: string
11269+
configs:
11270+
additionalProperties: {}
11271+
type: object
11272+
typeClassName:
11273+
type: string
1124911274
type: object
11250-
x-kubernetes-preserve-unknown-fields: true
1125111275
sourceType:
1125211276
type: string
1125311277
statefulConfig:

config/crd/bases/compute.functionmesh.io_functionmeshes.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ spec:
198198
type: object
199199
java:
200200
properties:
201+
entryClass:
202+
type: string
201203
extraDependenciesDir:
202204
type: string
205+
instancePath:
206+
type: string
203207
jar:
204208
type: string
205209
jarLocation:
@@ -3710,8 +3714,42 @@ spec:
37103714
type: object
37113715
showPreciseParallelism:
37123716
type: boolean
3717+
sinkConfig:
3718+
properties:
3719+
className:
3720+
type: string
3721+
configs:
3722+
type: object
3723+
x-kubernetes-preserve-unknown-fields: true
3724+
sinkType:
3725+
type: string
3726+
typeClassName:
3727+
type: string
3728+
type: object
37133729
skipToLatest:
37143730
type: boolean
3731+
sourceConfig:
3732+
properties:
3733+
batchSourceConfig:
3734+
properties:
3735+
discoveryTriggererClassName:
3736+
type: string
3737+
discoveryTriggererConfig:
3738+
type: object
3739+
x-kubernetes-preserve-unknown-fields: true
3740+
required:
3741+
- discoveryTriggererClassName
3742+
type: object
3743+
className:
3744+
type: string
3745+
configs:
3746+
type: object
3747+
x-kubernetes-preserve-unknown-fields: true
3748+
sourceType:
3749+
type: string
3750+
typeClassName:
3751+
type: string
3752+
type: object
37153753
statefulConfig:
37163754
properties:
37173755
pulsar:
@@ -4151,8 +4189,12 @@ spec:
41514189
type: object
41524190
java:
41534191
properties:
4192+
entryClass:
4193+
type: string
41544194
extraDependenciesDir:
41554195
type: string
4196+
instancePath:
4197+
type: string
41564198
jar:
41574199
type: string
41584200
jarLocation:
@@ -7750,8 +7792,12 @@ spec:
77507792
type: string
77517793
java:
77527794
properties:
7795+
entryClass:
7796+
type: string
77537797
extraDependenciesDir:
77547798
type: string
7799+
instancePath:
7800+
type: string
77557801
jar:
77567802
type: string
77577803
jarLocation:

config/crd/bases/compute.functionmesh.io_functions.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ spec:
195195
type: object
196196
java:
197197
properties:
198+
entryClass:
199+
type: string
198200
extraDependenciesDir:
199201
type: string
202+
instancePath:
203+
type: string
200204
jar:
201205
type: string
202206
jarLocation:
@@ -3707,8 +3711,42 @@ spec:
37073711
type: object
37083712
showPreciseParallelism:
37093713
type: boolean
3714+
sinkConfig:
3715+
properties:
3716+
className:
3717+
type: string
3718+
configs:
3719+
type: object
3720+
x-kubernetes-preserve-unknown-fields: true
3721+
sinkType:
3722+
type: string
3723+
typeClassName:
3724+
type: string
3725+
type: object
37103726
skipToLatest:
37113727
type: boolean
3728+
sourceConfig:
3729+
properties:
3730+
batchSourceConfig:
3731+
properties:
3732+
discoveryTriggererClassName:
3733+
type: string
3734+
discoveryTriggererConfig:
3735+
type: object
3736+
x-kubernetes-preserve-unknown-fields: true
3737+
required:
3738+
- discoveryTriggererClassName
3739+
type: object
3740+
className:
3741+
type: string
3742+
configs:
3743+
type: object
3744+
x-kubernetes-preserve-unknown-fields: true
3745+
sourceType:
3746+
type: string
3747+
typeClassName:
3748+
type: string
3749+
type: object
37123750
statefulConfig:
37133751
properties:
37143752
pulsar:

config/crd/bases/compute.functionmesh.io_sinks.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ spec:
190190
type: object
191191
java:
192192
properties:
193+
entryClass:
194+
type: string
193195
extraDependenciesDir:
194196
type: string
197+
instancePath:
198+
type: string
195199
jar:
196200
type: string
197201
jarLocation:

config/crd/bases/compute.functionmesh.io_sources.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ spec:
124124
type: string
125125
java:
126126
properties:
127+
entryClass:
128+
type: string
127129
extraDependenciesDir:
128130
type: string
131+
instancePath:
132+
type: string
129133
jar:
130134
type: string
131135
jarLocation:

0 commit comments

Comments
 (0)