Skip to content

Commit 5920faa

Browse files
committed
sdk: added CachedResourceEndpointSlice types
On-behalf-of: @SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
1 parent 5f9bfcb commit 5920faa

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

sdk/apis/cache/v1alpha1/types_cachedresource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ type ResourceCount struct {
161161
Local int `json:"local"`
162162
}
163163

164+
// CachedResourceReference is a reference to a CachedResource.
165+
type CachedResourceReference struct {
166+
// name is the name of the CachedResource the reference points to.
167+
//
168+
// +required
169+
// +kubebuilder:validation:Required
170+
// +kube:validation:MinLength=1
171+
Name string `json:"name"`
172+
}
173+
164174
// CachedResourceList contains a list of CachedResource
165175
//
166176
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
Copyright 2025 The KCP Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +crd
24+
// +genclient
25+
// +genclient:nonNamespaced
26+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27+
// +kubebuilder:subresource:status
28+
// +kubebuilder:resource:scope=Cluster,categories=kcp,path=cachedresourceendpointslices,singular=cachedresourceendpointslice
29+
// +kubebuilder:printcolumn:name="CachedResource",type="string",JSONPath=".spec.cachedResource.name"
30+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
31+
32+
// CachedResourceEndpointSlice is a sink for the endpoints of CachedResource virtual workspaces.
33+
type CachedResourceEndpointSlice struct {
34+
metav1.TypeMeta `json:",inline"`
35+
// +optional
36+
metav1.ObjectMeta `json:"metadata,omitempty"`
37+
38+
// spec holds the desired state:
39+
// - the targeted CachedResource
40+
Spec CachedResourceEndpointSliceSpec `json:"spec,omitempty"`
41+
42+
// status communicates the observed state:
43+
// the filtered list of endpoints for the Replication service.
44+
// +optional
45+
Status CachedResourceEndpointSliceStatus `json:"status,omitempty"`
46+
}
47+
48+
// CachedResourceEndpointSliceSpec defines the desired state of the CachedResourceEndpointSlice.
49+
type CachedResourceEndpointSliceSpec struct {
50+
// CachedResource points to the real CachedResource the slice is created for.
51+
//
52+
// +required
53+
// +kubebuilder:validation:Required
54+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="CachedResource reference must not be changed"
55+
CachedResource CachedResourceReference `json:"cachedResource"`
56+
}
57+
58+
// CachedResourceEndpointSliceStatus defines the observed state of CachedResourceEndpointSlice.
59+
type CachedResourceEndpointSliceStatus struct {
60+
// endpoints contains all the URLs of the Replication service.
61+
//
62+
// +optional
63+
// +listType=map
64+
// +listMapKey=url
65+
CachedResourceEndpoints []CachedResourceEndpoint `json:"endpoints"`
66+
}
67+
68+
// Using a struct provides an extension point
69+
70+
// CachedResourceEndpoint contains the endpoint information of a Replication service for a specific shard.
71+
type CachedResourceEndpoint struct {
72+
// url is an CachedResource virtual workspace URL.
73+
//
74+
// +kubebuilder:validation:MinLength=1
75+
// +kubebuilder:format:URL
76+
// +required
77+
URL string `json:"url"`
78+
}
79+
80+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
81+
82+
// CachedResourceEndpointSliceList is a list of CachedResourceEndpointSlice resources.
83+
type CachedResourceEndpointSliceList struct {
84+
metav1.TypeMeta `json:",inline"`
85+
metav1.ListMeta `json:"metadata"`
86+
87+
Items []CachedResourceEndpointSlice `json:"items"`
88+
}

0 commit comments

Comments
 (0)