|
| 1 | +// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package v1alpha1 |
| 5 | + |
| 6 | +import ( |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | +) |
| 9 | + |
| 10 | +// +kubebuilder:validation:Enum=isis |
| 11 | +type IGPType string |
| 12 | + |
| 13 | +// +kubebuilder:object:root=true |
| 14 | +// +kubebuilder:subresource:status |
| 15 | +// +kubebuilder:resource:path=igps |
| 16 | +// +kubebuilder:resource:singular=igp |
| 17 | +// +kubebuilder:resource:shortName=igp |
| 18 | +// +kubebuilder:printcolumn:name="Process name",type=string,JSONPath=`.spec.name` |
| 19 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 20 | +// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase" |
| 21 | + |
| 22 | +// IGP is the Schema for the igp API. |
| 23 | +type IGP struct { |
| 24 | + metav1.TypeMeta `json:",inline"` |
| 25 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 26 | + |
| 27 | + // Specification of the desired state of the resource. |
| 28 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 29 | + Spec IGPSpec `json:"spec,omitempty"` |
| 30 | + |
| 31 | + // Status of the resource. This is set and updated automatically. |
| 32 | + // Read-only. |
| 33 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 34 | + Status IGPStatus `json:"status,omitempty"` |
| 35 | +} |
| 36 | + |
| 37 | +// IGProcessSpec defines the desired state of Interior Gateway Protocol (IGP) process on a device. |
| 38 | +type IGPSpec struct { |
| 39 | + // The name of the routing instance. |
| 40 | + //+kubebuilder:validation:Required |
| 41 | + Name string `json:"name"` |
| 42 | + //+kubebuilder:validation:Required |
| 43 | + ISIS ISISSpec `json:"isis,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +// IGPStatus defines the observed state of an IGP process. |
| 47 | +type IGPStatus struct { |
| 48 | + // The conditions are a list of status objects that describe the state of the Interface. |
| 49 | + //+listType=map |
| 50 | + //+listMapKey=type |
| 51 | + //+patchStrategy=merge |
| 52 | + //+patchMergeKey=type |
| 53 | + //+optional |
| 54 | + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` |
| 55 | +} |
| 56 | + |
| 57 | +// +kubebuilder:object:root=true |
| 58 | + |
| 59 | +// IGPList contains a list of IGP (processes). |
| 60 | +type IGPList struct { |
| 61 | + metav1.TypeMeta `json:",inline"` |
| 62 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 63 | + Items []IGP `json:"items"` |
| 64 | +} |
| 65 | + |
| 66 | +// +kubebuilder:validation:Enum=Level1;Level2;Level12 |
| 67 | +type ISISLevel string |
| 68 | + |
| 69 | +const ( |
| 70 | + Level1 ISISLevel = "Level1" |
| 71 | + Level2 ISISLevel = "Level2" |
| 72 | + Level12 ISISLevel = "Level12" |
| 73 | +) |
| 74 | + |
| 75 | +// +kubebuilder:validation:Enum=v4-unicast;v6-unicast |
| 76 | +type ISISAF string |
| 77 | + |
| 78 | +const ( |
| 79 | + IPv4Unicast ISISAF = "v4-unicast" |
| 80 | + IPv6Unicast ISISAF = "v6-unicast" |
| 81 | +) |
| 82 | + |
| 83 | +type ISISSpec struct { |
| 84 | + // The Network Entity Title (NET) for the ISIS instance. |
| 85 | + //+kubebuilder:validation:Required |
| 86 | + NET string `json:"net"` |
| 87 | + // The is-type of the process (the level) |
| 88 | + //+kubebuilder:validation:Required |
| 89 | + Level ISISLevel `json:"level"` |
| 90 | + // Overload bit configuration for this ISIS instance |
| 91 | + //+kubebuilder:validation:Optional |
| 92 | + OverloadBit *OverloadBit `json:"overloadBit"` |
| 93 | + //+kubebuilder:validation:Required |
| 94 | + //+kubebuilder:validation:MinItems=1 |
| 95 | + //+kubebuilder:validation:MaxItems=2 |
| 96 | + AddressFamilies []ISISAF `json:"addressFamilies,omitempty"` |
| 97 | +} |
| 98 | + |
| 99 | +type OverloadBit struct { |
| 100 | + // Duration of the OverloadBit in seconds. |
| 101 | + //+kubebuilder:validation:Required |
| 102 | + //+kubebuilder:validation:Minimum=576 |
| 103 | + //+kubebuilder:validation:Maximum=86400 |
| 104 | + OnStartup uint32 `json:"onStartup"` |
| 105 | +} |
| 106 | + |
| 107 | +func init() { |
| 108 | + SchemeBuilder.Register(&IGP{}, &IGPList{}) |
| 109 | +} |
0 commit comments