Skip to content

Commit 78a05d5

Browse files
Support generic resource in FunctionMesh CRD
1 parent 5d18c1c commit 78a05d5

17 files changed

+2595
-58
lines changed

api/compute/v1alpha1/common.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,20 +369,23 @@ const (
369369

370370
// ResourceCondition The `Status` of a given `Condition` and the `Action` needed to reach the `Status`
371371
type ResourceCondition struct {
372-
Condition ResourceConditionType `json:"condition,omitempty"`
373-
Status metav1.ConditionStatus `json:"status,omitempty"`
374-
Action ReconcileAction `json:"action,omitempty"`
372+
Condition ResourceConditionType `json:"condition,omitempty"`
373+
Status metav1.ConditionStatus `json:"status,omitempty"`
374+
Action ReconcileAction `json:"action,omitempty"`
375+
ApiVersion string `json:"apiVersion,omitempty"`
376+
Kind string `json:"kind,omitempty"`
375377
}
376378

377379
type ResourceConditionType string
378380

379381
const (
380382
Orphaned ResourceConditionType = "Orphaned"
381383

382-
MeshReady ResourceConditionType = "MeshReady"
383-
FunctionReady ResourceConditionType = "FunctionReady"
384-
SourceReady ResourceConditionType = "SourceReady"
385-
SinkReady ResourceConditionType = "SinkReady"
384+
MeshReady ResourceConditionType = "MeshReady"
385+
FunctionReady ResourceConditionType = "FunctionReady"
386+
SourceReady ResourceConditionType = "SourceReady"
387+
SinkReady ResourceConditionType = "SinkReady"
388+
GenericResourceReady ResourceConditionType = "GenericResourceReady"
386389

387390
StatefulSetReady ResourceConditionType = "StatefulSetReady"
388391
ServiceReady ResourceConditionType = "ServiceReady"

api/compute/v1alpha1/functionmesh_types.go

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,50 @@ type FunctionMeshSpec struct {
2929
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3030
// Important: Run "make" to regenerate code after modifying this file
3131

32-
Sources []SourceSpec `json:"sources,omitempty"`
33-
Sinks []SinkSpec `json:"sinks,omitempty"`
34-
Functions []FunctionSpec `json:"functions,omitempty"`
32+
Sources []SourceSpec `json:"sources,omitempty"`
33+
Sinks []SinkSpec `json:"sinks,omitempty"`
34+
Functions []FunctionSpec `json:"functions,omitempty"`
35+
GenericResources []GenericResourceSpec `json:"genericResources,omitempty"`
36+
}
37+
38+
type GenericResourceSpec struct {
39+
// +kubebuilder:validation:Required
40+
APIVersion string `json:"apiVersion"`
41+
42+
// +kubebuilder:validation:Required
43+
Kind string `json:"kind"`
44+
45+
// +kubebuilder:validation:Required
46+
Name string `json:"name"`
47+
48+
// the field in the resource used to get the spec, default to "spec"
49+
// +kubebuilder:validation:Optional
50+
SpecFieldName string `json:"specFieldName,omitempty"`
51+
52+
// the field in the resource used to get the status, default to "status"
53+
// +kubebuilder:validation:Optional
54+
StatusFieldName string `json:"statusFieldName,omitempty"`
55+
56+
// the spec fields of the resource
57+
// +kubebuilder:validation:Optional
58+
// +kubebuilder:pruning:PreserveUnknownFields
59+
Spec *Config `json:"spec,omitempty"`
60+
61+
// The filed in the `Status` field of Resource used to check whether the resource is ready
62+
// should equal to ConditionTrue when it's ready
63+
ReadyField string `json:"readyField,omitempty"`
3564
}
3665

3766
// FunctionMeshStatus defines the observed state of FunctionMesh
3867
type FunctionMeshStatus struct {
3968
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
4069
// Important: Run "make" to regenerate code after modifying this file
41-
SourceConditions map[string]ResourceCondition `json:"sourceConditions,omitempty"`
42-
SinkConditions map[string]ResourceCondition `json:"sinkConditions,omitempty"`
43-
FunctionConditions map[string]ResourceCondition `json:"functionConditions,omitempty"`
44-
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
45-
Condition *ResourceCondition `json:"condition,omitempty"`
70+
SourceConditions map[string]ResourceCondition `json:"sourceConditions,omitempty"`
71+
SinkConditions map[string]ResourceCondition `json:"sinkConditions,omitempty"`
72+
FunctionConditions map[string]ResourceCondition `json:"functionConditions,omitempty"`
73+
GenericResourceConditions map[string]ResourceCondition `json:"genericCRConditions,omitempty"`
74+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
75+
Condition *ResourceCondition `json:"condition,omitempty"`
4676
}
4777

4878
// +genclient

api/compute/v1alpha1/zz_generated.deepcopy.go

Lines changed: 33 additions & 1 deletion
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-backendconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
{{- if eq .Values.admissionWebhook.certificate.provider "cert-manager" }}
77
{{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}}
88
{{- end }}
9-
controller-gen.kubebuilder.io/version: v0.9.2
9+
controller-gen.kubebuilder.io/version: v0.15.0
1010
name: backendconfigs.compute.functionmesh.io
1111
spec:
1212
conversion:

0 commit comments

Comments
 (0)