|
| 1 | +/* |
| 2 | + * Software Name : PowerDNS-Operator |
| 3 | + * |
| 4 | + * SPDX-FileCopyrightText: Copyright (c) PowerDNS-Operator contributors |
| 5 | + * SPDX-FileCopyrightText: Copyright (c) 2025 Orange Business Services SA |
| 6 | + * SPDX-License-Identifier: Apache-2.0 |
| 7 | + * |
| 8 | + * This software is distributed under the Apache 2.0 License, |
| 9 | + * see the "LICENSE" file for more details |
| 10 | + */ |
| 11 | + |
| 12 | +package v1alpha3 |
| 13 | + |
| 14 | +import ( |
| 15 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 16 | +) |
| 17 | + |
| 18 | +// +kubebuilder:object:root=true |
| 19 | +// +kubebuilder:storageversion |
| 20 | +// +kubebuilder:subresource:status |
| 21 | +// +kubebuilder:resource:scope=Cluster |
| 22 | + |
| 23 | +// +kubebuilder:printcolumn:name="Zone",type="string",JSONPath=".spec.zoneRef.name" |
| 24 | +// +kubebuilder:printcolumn:name="Name",type="string",JSONPath=".status.dnsEntryName" |
| 25 | +// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type" |
| 26 | +// +kubebuilder:printcolumn:name="TTL",type="integer",JSONPath=".spec.ttl" |
| 27 | +// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.syncStatus" |
| 28 | +// +kubebuilder:printcolumn:name="Records",type="string",JSONPath=".spec.records" |
| 29 | +// ClusterRRset is the Schema for the clusterrrsets API |
| 30 | +type ClusterRRset struct { |
| 31 | + metav1.TypeMeta `json:",inline"` |
| 32 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 33 | + |
| 34 | + Spec RRsetSpec `json:"spec,omitempty"` |
| 35 | + Status RRsetStatus `json:"status,omitempty"` |
| 36 | +} |
| 37 | + |
| 38 | +// +kubebuilder:object:root=true |
| 39 | + |
| 40 | +// ClusterRRsetList contains a list of ClusterRRset |
| 41 | +type ClusterRRsetList struct { |
| 42 | + metav1.TypeMeta `json:",inline"` |
| 43 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 44 | + Items []ClusterRRset `json:"items"` |
| 45 | +} |
| 46 | + |
| 47 | +func init() { |
| 48 | + SchemeBuilder.Register(&ClusterRRset{}, &ClusterRRsetList{}) |
| 49 | +} |
| 50 | + |
| 51 | +// IsInExpectedStatus returns true if Status.SyncStatus and Status.ObservedGeneration are, at least, at expected value |
| 52 | +func (r *ClusterRRset) IsInExpectedStatus(expectedMinimumObservedGeneration int64, expectedSyncStatus string) bool { |
| 53 | + return r.Status.ObservedGeneration != nil && |
| 54 | + *r.Status.ObservedGeneration >= expectedMinimumObservedGeneration && |
| 55 | + r.Status.SyncStatus != nil && |
| 56 | + *r.Status.SyncStatus == expectedSyncStatus |
| 57 | +} |
0 commit comments