Skip to content

Commit 3c984d6

Browse files
committed
[edgefunction] Split revisions into separate top-level object
1 parent 6cb6d91 commit 3c984d6

30 files changed

+1239
-447
lines changed

api/extensions/v1alpha1/edgefunction_hooks.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func (r *EdgeFunction) Default() {
4040
r.Spec.Runtime.Port = ptr.To(int32(8080))
4141
}
4242
}
43-
44-
if r.Status.Phase == "" {
45-
r.Status.Phase = EdgeFunctionPhasePreparing
46-
}
4743
}
4844

4945
var _ resourcestrategy.Validater = &EdgeFunction{}

api/extensions/v1alpha1/edgefunction_types.go

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -240,49 +240,11 @@ type EdgeFunctionSpec struct {
240240
Runtime *EdgeFunctionRuntime `json:"runtime,omitempty"`
241241
}
242242

243-
type EdgeFunctionRevision struct {
244-
// Ref is the reference to the function revision.
245-
Ref string `json:"ref"`
246-
247-
// CreatedAt is the time the function revision was created.
248-
CreatedAt metav1.Time `json:"createdAt"`
249-
250-
// Conditions describe the current conditions of the revision.
251-
// +optional
252-
Conditions []metav1.Condition `json:"conditions,omitempty"`
253-
}
254-
255-
type EdgeFunctionPhase string
256-
257-
const (
258-
// EdgeFunctionPhasePreparing means the function is being prepared.
259-
EdgeFunctionPhasePreparing EdgeFunctionPhase = "Preparing"
260-
// EdgeFunctionPhaseReady means the function is ready.
261-
EdgeFunctionPhaseReady EdgeFunctionPhase = "Ready"
262-
// EdgeFunctionPhaseUpdating means the function is being updated.
263-
EdgeFunctionPhaseUpdating EdgeFunctionPhase = "Updating"
264-
// EdgeFunctionPhaseNotReady means the function has no revisions ready to be used.
265-
EdgeFunctionPhaseNotReady EdgeFunctionPhase = "NotReady"
266-
// EdgeFunctionPhaseUnknown means the function is in an unknown state.
267-
EdgeFunctionPhaseUnknown EdgeFunctionPhase = "Unknown"
268-
)
269-
270243
type EdgeFunctionStatus struct {
271-
// Phase is the current phase of the function.
272-
Phase EdgeFunctionPhase `json:"phase"`
273-
274-
// Message is a human-readable message indicating details about the function.
275-
// +optional
276-
Message string `json:"message,omitempty"`
277-
278-
// Revisions is a list of function revisions.
279-
// Latest revision is the first element in the list.
280-
// +optional
281-
Revisions []EdgeFunctionRevision `json:"revisions,omitempty"`
282-
283-
// Live is the reference to the live function revision.
244+
// LiveRevision is the revision of the function that is currently being served
245+
// referenced by EdgeFunctionRevision object name.
284246
// +optional
285-
Live string `json:"live,omitempty"`
247+
LiveRevision string `json:"liveRevision,omitempty"`
286248

287249
// Conditions describe the current conditions of the EdgeFunction.
288250
// +optional
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
runtime "k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
"k8s.io/apiserver/pkg/registry/rest"
8+
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
9+
)
10+
11+
// +kubebuilder:object:root=true
12+
// +kubebuilder:subresource:status
13+
// +kubebuilder:subresource:log
14+
15+
// +genclient
16+
// +genclient:nonNamespaced
17+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
18+
//
19+
// EdgeFunctionRevision is a single revision of an EdgeFunction
20+
type EdgeFunctionRevision struct {
21+
metav1.TypeMeta `json:",inline"`
22+
metav1.ObjectMeta `json:"metadata,omitempty"`
23+
24+
Spec EdgeFunctionSpec `json:"spec,omitempty"`
25+
26+
Status EdgeFunctionRevisionStatus `json:"status,omitempty"`
27+
}
28+
29+
var (
30+
_ runtime.Object = &EdgeFunctionRevision{}
31+
_ resource.Object = &EdgeFunctionRevision{}
32+
_ resource.ObjectWithStatusSubResource = &EdgeFunctionRevision{}
33+
_ rest.SingularNameProvider = &EdgeFunctionRevision{}
34+
)
35+
36+
// GetObjectMeta implements resource.Object
37+
func (e *EdgeFunctionRevision) GetObjectMeta() *metav1.ObjectMeta {
38+
return &e.ObjectMeta
39+
}
40+
41+
// NamespaceScoped implements resource.Object
42+
func (e *EdgeFunctionRevision) NamespaceScoped() bool {
43+
return false
44+
}
45+
46+
// New implements resource.Object
47+
func (e *EdgeFunctionRevision) New() runtime.Object {
48+
return &EdgeFunctionRevision{}
49+
}
50+
51+
// NewList implements resource.Object
52+
func (e *EdgeFunctionRevision) NewList() runtime.Object {
53+
return &EdgeFunctionRevisionList{}
54+
}
55+
56+
// GetGroupVersionResource implements object.Object
57+
func (e *EdgeFunctionRevision) GetGroupVersionResource() schema.GroupVersionResource {
58+
return schema.GroupVersionResource{
59+
Group: SchemeGroupVersion.Group,
60+
Version: SchemeGroupVersion.Version,
61+
Resource: "edgefunctionrevisions",
62+
}
63+
}
64+
65+
// IsStorageVersion implements resource.Object
66+
func (e *EdgeFunctionRevision) IsStorageVersion() bool {
67+
return true
68+
}
69+
70+
// GetStatus implements resource.ObjectWithStatusSubResource
71+
func (e *EdgeFunctionRevision) GetStatus() resource.StatusSubResource {
72+
return &e.Status
73+
}
74+
75+
// GetSingularName implements rest.SingularNameProvider
76+
func (e *EdgeFunctionRevision) GetSingularName() string {
77+
return "edgefunctionrevision"
78+
}
79+
80+
// EdgeFunctionRevisionStatus defines the observed state of EdgeFunctionRevision
81+
type EdgeFunctionRevisionStatus struct {
82+
// Ref is the functions' uniquely identifying reference.
83+
Ref string `json:"ref"`
84+
85+
// Conditions represent the latest available observations of an EdgeFunctionRevision's current state.
86+
Conditions []metav1.Condition `json:"conditions,omitempty"`
87+
}
88+
89+
var _ resource.StatusSubResource = &EdgeFunctionRevisionStatus{}
90+
91+
func (ps *EdgeFunctionRevisionStatus) SubResourceName() string {
92+
return "status"
93+
}
94+
95+
func (ps *EdgeFunctionRevisionStatus) CopyTo(parent resource.ObjectWithStatusSubResource) {
96+
parent.(*EdgeFunctionRevision).Status = *ps
97+
}
98+
99+
// +kubebuilder:object:root=true
100+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
101+
102+
type EdgeFunctionRevisionList struct {
103+
metav1.TypeMeta `json:",inline"`
104+
metav1.ListMeta `json:"metadata,omitempty"`
105+
Items []EdgeFunctionRevision `json:"items"`
106+
}
107+
108+
var _ resource.ObjectList = &EdgeFunctionRevisionList{}
109+
110+
func (pl *EdgeFunctionRevisionList) GetListMeta() *metav1.ListMeta {
111+
return &pl.ListMeta
112+
}

api/extensions/v1alpha1/zz_generated.deepcopy.go

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

api/extensions/v1alpha1/zz_generated.register.go

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

0 commit comments

Comments
 (0)