|
| 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 | +// ISISSpec defines the desired state of ISIS |
| 11 | +type ISISSpec struct { |
| 12 | + // DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace. |
| 13 | + // Immutable. |
| 14 | + // +required |
| 15 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable" |
| 16 | + DeviceRef LocalObjectReference `json:"deviceRef"` |
| 17 | + |
| 18 | + // ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface. |
| 19 | + // This reference is used to link the Interface to its provider-specific configuration. |
| 20 | + // +optional |
| 21 | + ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"` |
| 22 | + |
| 23 | + // Instance is the name of the ISIS instance. |
| 24 | + // +required |
| 25 | + // +kubebuilder:validation:MinLength=1 |
| 26 | + // +kubebuilder:validation:MaxLength=63 |
| 27 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Instance is immutable" |
| 28 | + Instance string `json:"instance"` |
| 29 | + |
| 30 | + // NetworkEntityTitle is the NET of the ISIS instance. |
| 31 | + // +required |
| 32 | + // +kubebuilder:validation:Pattern=`^[a-fA-F0-9]{2}(\.[a-fA-F0-9]{4}){3,9}\.[a-fA-F0-9]{2}$` |
| 33 | + NetworkEntityTitle string `json:"networkEntityTitle"` |
| 34 | + |
| 35 | + // Type indicates the level of the ISIS instance. |
| 36 | + // +required |
| 37 | + Type ISISLevel `json:"type"` |
| 38 | + |
| 39 | + // OverloadBit indicates the overload bit of the ISIS instance. |
| 40 | + // +optional |
| 41 | + // +kubebuilder:default=Never |
| 42 | + OverloadBit OverloadBit `json:"overloadBit,omitempty"` |
| 43 | + |
| 44 | + // AddressFamilies is a list of address families for the ISIS instance. |
| 45 | + // +required |
| 46 | + // +listType=set |
| 47 | + // +kubebuilder:validation:MinItems=1 |
| 48 | + // +kubebuilder:validation:MaxItems=2 |
| 49 | + AddressFamilies []AddressFamily `json:"addressFamilies"` |
| 50 | + |
| 51 | + // Interfaces is a list of interfaces that are part of the ISIS instance. |
| 52 | + // +optional |
| 53 | + // +listType=atomic |
| 54 | + Interfaces []ISISInterface `json:"interfaces,omitempty"` |
| 55 | +} |
| 56 | + |
| 57 | +// ISISLevel represents the level of an ISIS instance. |
| 58 | +// +kubebuilder:validation:Enum=Level1;Level2;Level1-2 |
| 59 | +type ISISLevel string |
| 60 | + |
| 61 | +const ( |
| 62 | + ISISLevel1 ISISLevel = "Level1" |
| 63 | + ISISLevel2 ISISLevel = "Level2" |
| 64 | + ISISLevel12 ISISLevel = "Level1-2" |
| 65 | +) |
| 66 | + |
| 67 | +// OverloadBit represents the overload bit of an ISIS instance. |
| 68 | +// +kubebuilder:validation:Enum=Always;Never;OnStartup |
| 69 | +type OverloadBit string |
| 70 | + |
| 71 | +const ( |
| 72 | + OverloadBitAlways OverloadBit = "Always" |
| 73 | + OverloadBitNever OverloadBit = "Never" |
| 74 | + OverloadBitOnStartup OverloadBit = "OnStartup" |
| 75 | +) |
| 76 | + |
| 77 | +// AddressFamily represents the address family of an ISIS instance. |
| 78 | +// +kubebuilder:validation:Enum=IPv4Unicast;IPv6Unicast |
| 79 | +type AddressFamily string |
| 80 | + |
| 81 | +const ( |
| 82 | + AddressFamilyIPv4Unicast AddressFamily = "IPv4Unicast" |
| 83 | + AddressFamilyIPv6Unicast AddressFamily = "IPv6Unicast" |
| 84 | +) |
| 85 | + |
| 86 | +type ISISInterface struct { |
| 87 | + // Ref is a reference to the interface object. |
| 88 | + // The interface object must exist in the same namespace. |
| 89 | + // +required |
| 90 | + Ref LocalObjectReference `json:"ref"` |
| 91 | + |
| 92 | + // BFD contains BFD configuration for the interface. |
| 93 | + // +optional |
| 94 | + // +kubebuilder:default={} |
| 95 | + BFD ISISBFD `json:"bfd,omitzero"` |
| 96 | +} |
| 97 | + |
| 98 | +type ISISBFD struct { |
| 99 | + // Enabled indicates whether BFD is enabled on the interface. |
| 100 | + // +optional |
| 101 | + // +kubebuilder:default=false |
| 102 | + Enabled bool `json:"enabled"` |
| 103 | +} |
| 104 | + |
| 105 | +// ISISStatus defines the observed state of ISIS. |
| 106 | +type ISISStatus struct { |
| 107 | + // The conditions are a list of status objects that describe the state of the ISIS. |
| 108 | + //+listType=map |
| 109 | + //+listMapKey=type |
| 110 | + //+patchStrategy=merge |
| 111 | + //+patchMergeKey=type |
| 112 | + //+optional |
| 113 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 114 | +} |
| 115 | + |
| 116 | +// +kubebuilder:object:root=true |
| 117 | +// +kubebuilder:subresource:status |
| 118 | +// +kubebuilder:resource:path=isis |
| 119 | +// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceName` |
| 120 | +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` |
| 121 | +// +kubebuilder:printcolumn:name="Current",type=string,JSONPath=`.status.currentAdjacencies` |
| 122 | +// +kubebuilder:printcolumn:name="Desired",type=string,JSONPath=`.status.expectedAdjacencies` |
| 123 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 124 | + |
| 125 | +// ISIS is the Schema for the isis API |
| 126 | +type ISIS struct { |
| 127 | + metav1.TypeMeta `json:",inline"` |
| 128 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 129 | + |
| 130 | + // Specification of the desired state of the resource. |
| 131 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 132 | + // +required |
| 133 | + Spec ISISSpec `json:"spec,omitempty"` |
| 134 | + |
| 135 | + // Status of the resource. This is set and updated automatically. |
| 136 | + // Read-only. |
| 137 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 138 | + // +optional |
| 139 | + Status ISISStatus `json:"status,omitempty,omitzero"` |
| 140 | +} |
| 141 | + |
| 142 | +// +kubebuilder:object:root=true |
| 143 | + |
| 144 | +// ISISList contains a list of ISIS |
| 145 | +type ISISList struct { |
| 146 | + metav1.TypeMeta `json:",inline"` |
| 147 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 148 | + Items []ISIS `json:"items"` |
| 149 | +} |
| 150 | + |
| 151 | +func init() { |
| 152 | + SchemeBuilder.Register(&ISIS{}, &ISISList{}) |
| 153 | +} |
0 commit comments