|
| 1 | +/* |
| 2 | +Copyright 2026 Cozystack contributors. |
| 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 | +// KVEntrySpec is one entry in the LINSTOR-style key/value store. |
| 24 | +// |
| 25 | +// Upstream LINSTOR groups entries by an "instance" (e.g. "csi-volumes") |
| 26 | +// and addresses them by a free-form key (e.g. "Aux/csi-volume-annotations"). |
| 27 | +// We store one CRD per (instance, key) pair so neither half of the key |
| 28 | +// runs into k8s naming restrictions, and so the per-write blast radius is |
| 29 | +// a single object instead of an entire ConfigMap. |
| 30 | +type KVEntrySpec struct { |
| 31 | + // instance is the LINSTOR KV instance name. Free-form string. |
| 32 | + // +required |
| 33 | + Instance string `json:"instance"` |
| 34 | + |
| 35 | + // key is the free-form key inside the instance. May contain '/', '.', |
| 36 | + // uppercase, etc. — anything golinstor sends. |
| 37 | + // +required |
| 38 | + Key string `json:"key"` |
| 39 | + |
| 40 | + // value is the opaque payload. |
| 41 | + // +optional |
| 42 | + Value string `json:"value,omitempty"` |
| 43 | +} |
| 44 | + |
| 45 | +// KVEntryStatus is currently empty: KVEntries are pure config and have no |
| 46 | +// observed state. |
| 47 | +type KVEntryStatus struct { |
| 48 | + // conditions represent the current state of the KVEntry. Reserved for |
| 49 | + // future use; populated by reconcilers if any are introduced. |
| 50 | + // +listType=map |
| 51 | + // +listMapKey=type |
| 52 | + // +optional |
| 53 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// +kubebuilder:object:root=true |
| 57 | +// +kubebuilder:subresource:status |
| 58 | +// +kubebuilder:resource:scope=Cluster |
| 59 | + |
| 60 | +// KVEntry is the Schema for the kventries API |
| 61 | +type KVEntry struct { |
| 62 | + metav1.TypeMeta `json:",inline"` |
| 63 | + |
| 64 | + // metadata is a standard object metadata |
| 65 | + // +optional |
| 66 | + metav1.ObjectMeta `json:"metadata,omitzero"` |
| 67 | + |
| 68 | + // spec defines the desired state of KVEntry |
| 69 | + // +required |
| 70 | + Spec KVEntrySpec `json:"spec"` |
| 71 | + |
| 72 | + // status defines the observed state of KVEntry |
| 73 | + // +optional |
| 74 | + Status KVEntryStatus `json:"status,omitzero"` |
| 75 | +} |
| 76 | + |
| 77 | +// +kubebuilder:object:root=true |
| 78 | + |
| 79 | +// KVEntryList contains a list of KVEntry |
| 80 | +type KVEntryList struct { |
| 81 | + metav1.TypeMeta `json:",inline"` |
| 82 | + metav1.ListMeta `json:"metadata,omitzero"` |
| 83 | + Items []KVEntry `json:"items"` |
| 84 | +} |
| 85 | + |
| 86 | +func init() { |
| 87 | + SchemeBuilder.Register(&KVEntry{}, &KVEntryList{}) |
| 88 | +} |
0 commit comments