|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1alpha1 |
| 16 | + |
| 17 | +import ( |
| 18 | + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" |
| 19 | + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +var FirestoreDocumentGVK = GroupVersion.WithKind("FirestoreDocument") |
| 24 | + |
| 25 | +// FirestoreDocumentSpec defines the desired state of FirestoreDocument |
| 26 | +// +kcc:spec:proto=google.firestore.v1.Document |
| 27 | +type FirestoreDocumentSpec struct { |
| 28 | + // The FirestoreDocument name. If not given, the metadata.name will be used. |
| 29 | + ResourceID *string `json:"resourceID,omitempty"` |
| 30 | + |
| 31 | + // // The resource name of the document, for example |
| 32 | + // // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. |
| 33 | + // // +kcc:proto:field=google.firestore.v1.Document.name |
| 34 | + // Name *string `json:"name,omitempty"` |
| 35 | + |
| 36 | + // Fields holds the field values; values follow JSON typing conventions. |
| 37 | + Fields map[string]apiextensionsv1.JSON `json:"fields,omitempty"` |
| 38 | +} |
| 39 | + |
| 40 | +// FirestoreDocumentStatus defines the config connector machine state of FirestoreDocument |
| 41 | +type FirestoreDocumentStatus struct { |
| 42 | + /* Conditions represent the latest available observations of the |
| 43 | + object's current state. */ |
| 44 | + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` |
| 45 | + |
| 46 | + // ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |
| 47 | + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` |
| 48 | + |
| 49 | + // A unique specifier for the FirestoreDocument resource in GCP. |
| 50 | + ExternalRef *string `json:"externalRef,omitempty"` |
| 51 | + |
| 52 | + // ObservedState is the state of the resource as most recently observed in GCP. |
| 53 | + ObservedState *FirestoreDocumentObservedState `json:"observedState,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// FirestoreDocumentObservedState is the state of the FirestoreDocument resource as most recently observed in GCP. |
| 57 | +// +kcc:observedstate:proto=google.firestore.v1.Document |
| 58 | +type FirestoreDocumentObservedState struct { |
| 59 | + // Output only. The time at which the document was created. |
| 60 | + // |
| 61 | + // This value increases monotonically when a document is deleted then |
| 62 | + // recreated. It can also be compared to values from other documents and |
| 63 | + // the `read_time` of a query. |
| 64 | + // +kcc:proto:field=google.firestore.v1.Document.create_time |
| 65 | + CreateTime *string `json:"createTime,omitempty"` |
| 66 | + |
| 67 | + // Output only. The time at which the document was last changed. |
| 68 | + // |
| 69 | + // This value is initially set to the `create_time` then increases |
| 70 | + // monotonically with each change to the document. It can also be |
| 71 | + // compared to values from other documents and the `read_time` of a query. |
| 72 | + // +kcc:proto:field=google.firestore.v1.Document.update_time |
| 73 | + UpdateTime *string `json:"updateTime,omitempty"` |
| 74 | +} |
| 75 | + |
| 76 | +// +genclient |
| 77 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 78 | +// +kubebuilder:resource:categories=gcp,shortName=gcpfirestoredocument;gcpfirestoredocuments |
| 79 | +// +kubebuilder:subresource:status |
| 80 | +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true" |
| 81 | +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" |
| 82 | +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" |
| 83 | +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" |
| 84 | +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" |
| 85 | + |
| 86 | +// FirestoreDocument is the Schema for the FirestoreDocument API |
| 87 | +// +k8s:openapi-gen=true |
| 88 | +type FirestoreDocument struct { |
| 89 | + metav1.TypeMeta `json:",inline"` |
| 90 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 91 | + |
| 92 | + // +required |
| 93 | + Spec FirestoreDocumentSpec `json:"spec,omitempty"` |
| 94 | + Status FirestoreDocumentStatus `json:"status,omitempty"` |
| 95 | +} |
| 96 | + |
| 97 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 98 | +// FirestoreDocumentList contains a list of FirestoreDocument |
| 99 | +type FirestoreDocumentList struct { |
| 100 | + metav1.TypeMeta `json:",inline"` |
| 101 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 102 | + Items []FirestoreDocument `json:"items"` |
| 103 | +} |
| 104 | + |
| 105 | +func init() { |
| 106 | + SchemeBuilder.Register(&FirestoreDocument{}, &FirestoreDocumentList{}) |
| 107 | +} |
0 commit comments