|
| 1 | +/* |
| 2 | +Copyright 2025 The Kube Bind 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 | + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" |
| 23 | +) |
| 24 | + |
| 25 | +// Collection groups multiple Modules into a logical group. This functions as a folder in the UI. |
| 26 | +// |
| 27 | +// +crd |
| 28 | +// +genclient |
| 29 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 30 | +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings |
| 31 | +// +kubebuilder:subresource:status |
| 32 | +// +kubebuilder:printcolumn:name="Description",type="string",JSONPath=`.spec.description` |
| 33 | +// +kubebuilder:printcolumn:name="Modules",type="integer",JSONPath=`.spec.modules[*]` |
| 34 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 |
| 35 | +type Collection struct { |
| 36 | + metav1.TypeMeta `json:",inline"` |
| 37 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 38 | + |
| 39 | + // spec specifies the collection. |
| 40 | + // +required |
| 41 | + // +kubebuilder:validation:Required |
| 42 | + Spec CollectionSpec `json:"spec"` |
| 43 | + |
| 44 | + // status contains reconciliation information for the collection. |
| 45 | + Status CollectionStatus `json:"status,omitempty"` |
| 46 | +} |
| 47 | + |
| 48 | +func (in *Collection) GetConditions() conditionsapi.Conditions { |
| 49 | + return in.Status.Conditions |
| 50 | +} |
| 51 | + |
| 52 | +func (in *Collection) SetConditions(conditions conditionsapi.Conditions) { |
| 53 | + in.Status.Conditions = conditions |
| 54 | +} |
| 55 | + |
| 56 | +// CollectionSpec defines the desired state of Collection. |
| 57 | +type CollectionSpec struct { |
| 58 | + // description is a human readable description of this collection. |
| 59 | + // |
| 60 | + // +optional |
| 61 | + Description string `json:"description,omitempty"` |
| 62 | + |
| 63 | + // modules is a list of module references that are part of this collection. |
| 64 | + // |
| 65 | + // +required |
| 66 | + // +kubebuilder:validation:Required |
| 67 | + // +kubebuilder:validation:MinItems=1 |
| 68 | + Modules []ModuleReference `json:"modules"` |
| 69 | +} |
| 70 | + |
| 71 | +// ModuleReference references a Module by name. |
| 72 | +type ModuleReference struct { |
| 73 | + // name is the name of the module. |
| 74 | + // |
| 75 | + // +required |
| 76 | + // +kubebuilder:validation:Required |
| 77 | + Name string `json:"name"` |
| 78 | +} |
| 79 | + |
| 80 | +// CollectionStatus stores status information about a Collection. |
| 81 | +type CollectionStatus struct { |
| 82 | + // conditions is a list of conditions that apply to the Collection. |
| 83 | + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` |
| 84 | +} |
| 85 | + |
| 86 | +// CollectionList is the list of Collection. |
| 87 | +// |
| 88 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 89 | +type CollectionList struct { |
| 90 | + metav1.TypeMeta `json:",inline"` |
| 91 | + metav1.ListMeta `json:"metadata"` |
| 92 | + |
| 93 | + Items []Collection `json:"items"` |
| 94 | +} |
0 commit comments