|
| 1 | +// Copyright (c) 2026 Aiven, Helsinki, Finland. https://aiven.io/ |
| 2 | + |
| 3 | +package v1alpha1 |
| 4 | + |
| 5 | +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | + |
| 7 | +// UpgradePipelineStepSpec defines the desired state of UpgradePipelineStep. |
| 8 | +type UpgradePipelineStepSpec struct { |
| 9 | + AuthSecretRefField `json:",inline"` |
| 10 | + |
| 11 | + // +kubebuilder:validation:MinLength=1 |
| 12 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" |
| 13 | + // OrganizationID is the Aiven organization ID that owns the upgrade pipeline step. |
| 14 | + OrganizationID string `json:"organizationId"` |
| 15 | + |
| 16 | + // +kubebuilder:validation:MinLength=1 |
| 17 | + // +kubebuilder:validation:MaxLength=63 |
| 18 | + // +kubebuilder:validation:Pattern="^[a-zA-Z0-9_-]+$" |
| 19 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" |
| 20 | + // SourceProjectName is the project name of the service that must be upgraded first. |
| 21 | + SourceProjectName string `json:"sourceProjectName"` |
| 22 | + |
| 23 | + // +kubebuilder:validation:MinLength=1 |
| 24 | + // +kubebuilder:validation:MaxLength=63 |
| 25 | + // +kubebuilder:validation:Pattern="^[a-z][-a-z0-9]+$" |
| 26 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" |
| 27 | + // SourceServiceName is the service name that must be upgraded first. |
| 28 | + SourceServiceName string `json:"sourceServiceName"` |
| 29 | + |
| 30 | + // +kubebuilder:validation:MinLength=1 |
| 31 | + // +kubebuilder:validation:MaxLength=63 |
| 32 | + // +kubebuilder:validation:Pattern="^[a-zA-Z0-9_-]+$" |
| 33 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" |
| 34 | + // DestinationProjectName is the project name of the service that waits for the source service. |
| 35 | + DestinationProjectName string `json:"destinationProjectName"` |
| 36 | + |
| 37 | + // +kubebuilder:validation:MinLength=1 |
| 38 | + // +kubebuilder:validation:MaxLength=63 |
| 39 | + // +kubebuilder:validation:Pattern="^[a-z][-a-z0-9]+$" |
| 40 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" |
| 41 | + // DestinationServiceName is the service name that waits for the source service. |
| 42 | + DestinationServiceName string `json:"destinationServiceName"` |
| 43 | + |
| 44 | + // +kubebuilder:validation:Minimum=0 |
| 45 | + // +kubebuilder:default=7 |
| 46 | + // AutoValidationDelayDays is the number of days before Aiven can automatically validate the source service. |
| 47 | + AutoValidationDelayDays *int `json:"autoValidationDelayDays,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +// UpgradePipelineStepLastValidationStatus describes the last validation observed for an upgrade pipeline step. |
| 51 | +type UpgradePipelineStepLastValidationStatus struct { |
| 52 | + // Comment is the validation comment. |
| 53 | + Comment string `json:"comment,omitempty"` |
| 54 | + |
| 55 | + // ValidatedAt is the time the validation was created. |
| 56 | + ValidatedAt *metav1.Time `json:"validatedAt,omitempty"` |
| 57 | + |
| 58 | + // ValidatedByUser is the user who created the validation. It is empty for auto-validation. |
| 59 | + ValidatedByUser string `json:"validatedByUser,omitempty"` |
| 60 | +} |
| 61 | + |
| 62 | +// UpgradePipelineStepStatus defines the observed state of UpgradePipelineStep. |
| 63 | +type UpgradePipelineStepStatus struct { |
| 64 | + // Conditions represent the latest available observations of an UpgradePipelineStep state. |
| 65 | + Conditions []metav1.Condition `json:"conditions"` |
| 66 | + |
| 67 | + // ID is the Aiven upgrade pipeline step ID. |
| 68 | + ID string `json:"id,omitempty"` |
| 69 | + |
| 70 | + // LastValidation contains the last validation information returned by the Aiven API. |
| 71 | + LastValidation *UpgradePipelineStepLastValidationStatus `json:"lastValidation,omitempty"` |
| 72 | +} |
| 73 | + |
| 74 | +// +kubebuilder:object:root=true |
| 75 | +// +kubebuilder:subresource:status |
| 76 | + |
| 77 | +// UpgradePipelineStep is the Schema for the upgradepipelinesteps API. |
| 78 | +// +kubebuilder:printcolumn:name="Organization",type="string",JSONPath=".spec.organizationId" |
| 79 | +// +kubebuilder:printcolumn:name="Source Project",type="string",JSONPath=".spec.sourceProjectName" |
| 80 | +// +kubebuilder:printcolumn:name="Source Service",type="string",JSONPath=".spec.sourceServiceName" |
| 81 | +// +kubebuilder:printcolumn:name="Destination Project",type="string",JSONPath=".spec.destinationProjectName" |
| 82 | +// +kubebuilder:printcolumn:name="Destination Service",type="string",JSONPath=".spec.destinationServiceName" |
| 83 | +// +kubebuilder:printcolumn:name="Step ID",type="string",JSONPath=".status.id" |
| 84 | +type UpgradePipelineStep struct { |
| 85 | + metav1.TypeMeta `json:",inline"` |
| 86 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 87 | + |
| 88 | + Spec UpgradePipelineStepSpec `json:"spec,omitempty"` |
| 89 | + Status UpgradePipelineStepStatus `json:"status,omitempty"` |
| 90 | +} |
| 91 | + |
| 92 | +var _ AivenManagedObject = &UpgradePipelineStep{} |
| 93 | + |
| 94 | +func (*UpgradePipelineStep) NoSecret() bool { |
| 95 | + return true |
| 96 | +} |
| 97 | + |
| 98 | +func (in *UpgradePipelineStep) AuthSecretRef() *AuthSecretReference { |
| 99 | + return in.Spec.AuthSecretRef |
| 100 | +} |
| 101 | + |
| 102 | +func (in *UpgradePipelineStep) Conditions() *[]metav1.Condition { |
| 103 | + return &in.Status.Conditions |
| 104 | +} |
| 105 | + |
| 106 | +func (in *UpgradePipelineStep) GetObjectMeta() *metav1.ObjectMeta { |
| 107 | + return &in.ObjectMeta |
| 108 | +} |
| 109 | + |
| 110 | +// +kubebuilder:object:root=true |
| 111 | + |
| 112 | +// UpgradePipelineStepList contains a list of UpgradePipelineStep. |
| 113 | +type UpgradePipelineStepList struct { |
| 114 | + metav1.TypeMeta `json:",inline"` |
| 115 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 116 | + Items []UpgradePipelineStep `json:"items"` |
| 117 | +} |
| 118 | + |
| 119 | +func init() { |
| 120 | + SchemeBuilder.Register(&UpgradePipelineStep{}, &UpgradePipelineStepList{}) |
| 121 | +} |
0 commit comments