Skip to content

Commit 929ca37

Browse files
authored
Improve Operator (#198)
1 parent a494f50 commit 929ca37

16 files changed

+209
-233
lines changed

operator/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ docker-push: ## Push docker image with the manager.
123123
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
124124
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
125125
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
126-
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
126+
#PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
127+
PLATFORMS ?= linux/arm64,linux/amd64
127128
.PHONY: docker-buildx
128129
docker-buildx: ## Build and push docker image for the manager for cross-platform support
129130
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile

operator/api/v1alpha1/function_types.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -25,30 +26,39 @@ import (
2526
// +kubebuilder:validation:Optional
2627
type FunctionSpec struct {
2728
// Display name of the function
29+
// +kubebuilder:validation:Optional
2830
DisplayName string `json:"displayName,omitempty"`
2931
// Description of the function
32+
// +kubebuilder:validation:Optional
3033
Description string `json:"description,omitempty"`
3134
// Package name
3235
// +kubebuilder:validation:Required
3336
Package string `json:"package"`
3437
// Module name
3538
// +kubebuilder:validation:Required
3639
Module string `json:"module"`
40+
// +kubebuilder:validation:Optional
41+
SubscriptionName string `json:"subscriptionName,omitempty"`
3742
// List of sources
43+
// +kubebuilder:validation:Optional
3844
Sources []SourceSpec `json:"sources,omitempty"`
3945
// Request source
40-
RequestSource SourceSpec `json:"requestSource,omitempty"`
46+
// +kubebuilder:validation:Optional
47+
RequestSource *SourceSpec `json:"requestSource,omitempty"`
4148
// Sink specifies the sink configuration
42-
Sink SinkSpec `json:"sink,omitempty"`
49+
// +kubebuilder:validation:Optional
50+
Sink *SinkSpec `json:"sink,omitempty"`
4351
// Configurations as key-value pairs
44-
Config map[string]string `json:"config,omitempty"`
52+
// +kubebuilder:validation:Optional
53+
Config map[string]v1.JSON `json:"config,omitempty"`
4554
}
4655

4756
// SourceSpec defines a source or sink specification
4857
// +kubebuilder:object:generate=true
4958
// +kubebuilder:validation:Optional
5059
type SourceSpec struct {
5160
// Pulsar source specification
61+
// +kubebuilder:validation:Optional
5262
Pulsar *PulsarSourceSpec `json:"pulsar,omitempty"`
5363
}
5464

@@ -59,16 +69,14 @@ type PulsarSourceSpec struct {
5969
// Topic name
6070
// +kubebuilder:validation:Required
6171
Topic string `json:"topic"`
62-
// Subscription name
63-
// +kubebuilder:validation:Required
64-
SubscriptionName string `json:"subscriptionName"`
6572
}
6673

6774
// SinkSpec defines a sink specification
6875
// +kubebuilder:object:generate=true
6976
// +kubebuilder:validation:Optional
7077
type SinkSpec struct {
7178
// Pulsar sink specification
79+
// +kubebuilder:validation:Optional
7280
Pulsar *PulsarSinkSpec `json:"pulsar,omitempty"`
7381
}
7482

operator/api/v1alpha1/packages_types.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,36 @@ import (
2323
// ConfigItem defines a configuration item for a module
2424
type ConfigItem struct {
2525
// DisplayName is the human-readable name of the config item
26-
DisplayName string `json:"displayName"`
26+
// +kubebuilder:validation:Optional
27+
DisplayName string `json:"displayName,omitempty"`
2728
// Description provides additional information about the config item
28-
Description string `json:"description"`
29+
// +kubebuilder:validation:Optional
30+
Description string `json:"description,omitempty"`
2931
// Type specifies the data type of the config item
30-
Type string `json:"type"`
32+
// +kubebuilder:validation:Optional
33+
Type string `json:"type,omitempty"`
3134
// Required indicates whether this config item is mandatory
32-
Required bool `json:"required"`
35+
// +kubebuilder:validation:Optional
36+
Required bool `json:"required,omitempty"`
3337
}
3438

3539
// Module defines a module within a package
3640
type Module struct {
3741
// DisplayName is the human-readable name of the module
38-
DisplayName string `json:"displayName"`
42+
// +kubebuilder:validation:Optional
43+
DisplayName string `json:"displayName,omitempty"`
3944
// Description provides additional information about the module
40-
Description string `json:"description"`
45+
// +kubebuilder:validation:Optional
46+
Description string `json:"description,omitempty"`
4147
// SourceSchema defines the input schema for the module
48+
// +kubebuilder:validation:Optional
4249
SourceSchema string `json:"sourceSchema,omitempty"`
4350
// SinkSchema defines the output schema for the module
51+
// +kubebuilder:validation:Optional
4452
SinkSchema string `json:"sinkSchema,omitempty"`
4553
// Config is a list of configuration items for the module
46-
Config []ConfigItem `json:"config,omitempty"`
54+
// +kubebuilder:validation:Optional
55+
Config map[string]ConfigItem `json:"config,omitempty"`
4756
}
4857

4958
// CloudType defines cloud function package configuration
@@ -55,17 +64,21 @@ type CloudType struct {
5564
// FunctionType defines the function type configuration
5665
type FunctionType struct {
5766
// Cloud contains cloud function package configuration
67+
// +kubebuilder:validation:Optional
5868
Cloud *CloudType `json:"cloud,omitempty"`
5969
}
6070

6171
// PackageSpec defines the desired state of Package
6272
type PackageSpec struct {
6373
// DisplayName is the human-readable name of the package
64-
DisplayName string `json:"displayName"`
74+
// +kubebuilder:validation:Optional
75+
DisplayName string `json:"displayName,omitempty"`
6576
// Logo is the URL or base64 encoded image for the package logo
77+
// +kubebuilder:validation:Optional
6678
Logo string `json:"logo,omitempty"`
6779
// Description provides additional information about the package
68-
Description string `json:"description"`
80+
// +kubebuilder:validation:Optional
81+
Description string `json:"description,omitempty"`
6982
// FunctionType contains function type configuration
7083
FunctionType FunctionType `json:"functionType"`
7184
// Modules is a map of module names to their configurations

operator/api/v1alpha1/zz_generated.deepcopy.go

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

operator/cmd/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func main() {
9595
opts.BindFlags(flag.CommandLine)
9696
flag.Parse()
9797

98-
// Build Config struct (no need to set env)
9998
config := controller.Config{
10099
PulsarServiceURL: pulsarServiceUrl,
101100
PulsarAuthPlugin: pulsarAuthPlugin,

operator/config/crd/bases/fs.functionstream.github.io_functions.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
properties:
4242
config:
4343
additionalProperties:
44-
type: string
44+
x-kubernetes-preserve-unknown-fields: true
4545
description: Configurations as key-value pairs
4646
type: object
4747
description:
@@ -62,19 +62,15 @@ spec:
6262
pulsar:
6363
description: Pulsar source specification
6464
properties:
65-
subscriptionName:
66-
description: Subscription name
67-
type: string
6865
topic:
6966
description: Topic name
7067
type: string
7168
required:
72-
- subscriptionName
7369
- topic
7470
type: object
7571
type: object
7672
sink:
77-
description: sink
73+
description: Sink specifies the sink configuration
7874
properties:
7975
pulsar:
8076
description: Pulsar sink specification
@@ -94,18 +90,16 @@ spec:
9490
pulsar:
9591
description: Pulsar source specification
9692
properties:
97-
subscriptionName:
98-
description: Subscription name
99-
type: string
10093
topic:
10194
description: Topic name
10295
type: string
10396
required:
104-
- subscriptionName
10597
- topic
10698
type: object
10799
type: object
108100
type: array
101+
subscriptionName:
102+
type: string
109103
required:
110104
- module
111105
- package

operator/config/crd/bases/fs.functionstream.github.io_packages.yaml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ spec:
7171
description: Module defines a module within a package
7272
properties:
7373
config:
74-
description: Config is a list of configuration items for the
75-
module
76-
items:
74+
additionalProperties:
7775
description: ConfigItem defines a configuration item for a
7876
module
7977
properties:
@@ -93,13 +91,10 @@ spec:
9391
description: Type specifies the data type of the config
9492
item
9593
type: string
96-
required:
97-
- description
98-
- displayName
99-
- required
100-
- type
10194
type: object
102-
type: array
95+
description: Config is a list of configuration items for the
96+
module
97+
type: object
10398
description:
10499
description: Description provides additional information about
105100
the module
@@ -113,15 +108,10 @@ spec:
113108
sourceSchema:
114109
description: SourceSchema defines the input schema for the module
115110
type: string
116-
required:
117-
- description
118-
- displayName
119111
type: object
120112
description: Modules is a map of module names to their configurations
121113
type: object
122114
required:
123-
- description
124-
- displayName
125115
- functionType
126116
- modules
127117
type: object

operator/config/rbac/role.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ kind: ClusterRole
44
metadata:
55
name: manager-role
66
rules:
7-
- apiGroups:
8-
- ""
9-
resources:
10-
- configmaps
11-
verbs:
12-
- create
13-
- delete
14-
- get
15-
- list
16-
- patch
17-
- update
18-
- watch
197
- apiGroups:
208
- apps
219
resources:

operator/deploy/chart/templates/crd/fs.functionstream.github.io_functions.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
properties:
4848
config:
4949
additionalProperties:
50-
type: string
50+
x-kubernetes-preserve-unknown-fields: true
5151
description: Configurations as key-value pairs
5252
type: object
5353
description:
@@ -68,19 +68,15 @@ spec:
6868
pulsar:
6969
description: Pulsar source specification
7070
properties:
71-
subscriptionName:
72-
description: Subscription name
73-
type: string
7471
topic:
7572
description: Topic name
7673
type: string
7774
required:
78-
- subscriptionName
7975
- topic
8076
type: object
8177
type: object
8278
sink:
83-
description: sink
79+
description: Sink specifies the sink configuration
8480
properties:
8581
pulsar:
8682
description: Pulsar sink specification
@@ -100,18 +96,16 @@ spec:
10096
pulsar:
10197
description: Pulsar source specification
10298
properties:
103-
subscriptionName:
104-
description: Subscription name
105-
type: string
10699
topic:
107100
description: Topic name
108101
type: string
109102
required:
110-
- subscriptionName
111103
- topic
112104
type: object
113105
type: object
114106
type: array
107+
subscriptionName:
108+
type: string
115109
required:
116110
- module
117111
- package

0 commit comments

Comments
 (0)