Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apis/firestore/v1alpha1/backupschedule_identity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1
15 changes: 15 additions & 0 deletions apis/firestore/v1alpha1/backupschedule_reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1
122 changes: 122 additions & 0 deletions apis/firestore/v1alpha1/backupschedule_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import (
v1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/firestore/v1beta1"
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var FirestoreDatabaseBackupScheduleGVK = GroupVersion.WithKind("FirestoreDatabaseBackupSchedule")

// FirestoreDatabaseBackupScheduleSpec defines the desired state of FirestoreDatabaseBackupSchedule
// +kcc:spec:proto=google.firestore.admin.v1.BackupSchedule
type FirestoreDatabaseBackupScheduleSpec struct {
/* The database that this resource belongs to. */
// +required
DatabaseRef v1beta1.FirestoreDatabaseRef `json:"databaseRef"`

// At what relative time in the future, compared to its creation time,
// the backup should be deleted, e.g. keep backups for 7 days.
//
// The maximum supported retention period is 14 weeks.
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.retention
Retention *string `json:"retention,omitempty"`

// For a schedule that runs daily.
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.daily_recurrence
DailyRecurrence *DailyRecurrence `json:"dailyRecurrence,omitempty"`

// For a schedule that runs weekly on a specific day.
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.weekly_recurrence
WeeklyRecurrence *WeeklyRecurrence `json:"weeklyRecurrence,omitempty"`
}

// FirestoreDatabaseBackupScheduleStatus defines the config connector machine state of FirestoreDatabaseBackupSchedule
type FirestoreDatabaseBackupScheduleStatus struct {
/* Conditions represent the latest available observations of the
object's current state. */
Conditions []v1alpha1.Condition `json:"conditions,omitempty"`

// 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.
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`

// A unique specifier for the FirestoreDatabaseBackupSchedule resource in GCP.
ExternalRef *string `json:"externalRef,omitempty"`

// ObservedState is the state of the resource as most recently observed in GCP.
ObservedState *FirestoreDatabaseBackupScheduleObservedState `json:"observedState,omitempty"`
}

// FirestoreDatabaseBackupScheduleObservedState is the state of the FirestoreDatabaseBackupSchedule resource as most recently observed in GCP.
// +kcc:observedstate:proto=google.firestore.admin.v1.BackupSchedule
type FirestoreDatabaseBackupScheduleObservedState struct {
// Output only. The unique backup schedule identifier across all locations and
// databases for the given project.
//
// This will be auto-assigned.
//
// Format is
// `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.name
Name *string `json:"name,omitempty"`

// Output only. The timestamp at which this backup schedule was created and
// effective since.
//
// No backups will be created for this schedule before this time.
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.create_time
CreateTime *string `json:"createTime,omitempty"`

// Output only. The timestamp at which this backup schedule was most recently
// updated. When a backup schedule is first created, this is the same as
// create_time.
// +kcc:proto:field=google.firestore.admin.v1.BackupSchedule.update_time
UpdateTime *string `json:"updateTime,omitempty"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=gcp,shortName=gcpfirestoredatabasebackupschedule;gcpfirestoredatabasebackupschedules
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true"
// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date"
// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded"
// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'"
// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'"

// FirestoreDatabaseBackupSchedule is the Schema for the FirestoreDatabaseBackupSchedule API
// +k8s:openapi-gen=true
type FirestoreDatabaseBackupSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +required
Spec FirestoreDatabaseBackupScheduleSpec `json:"spec,omitempty"`
Status FirestoreDatabaseBackupScheduleStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FirestoreDatabaseBackupScheduleList contains a list of FirestoreDatabaseBackupSchedule
type FirestoreDatabaseBackupScheduleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FirestoreDatabaseBackupSchedule `json:"items"`
}

func init() {
SchemeBuilder.Register(&FirestoreDatabaseBackupSchedule{}, &FirestoreDatabaseBackupScheduleList{})
}
15 changes: 15 additions & 0 deletions apis/firestore/v1alpha1/document_identity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1
15 changes: 15 additions & 0 deletions apis/firestore/v1alpha1/document_reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1
106 changes: 106 additions & 0 deletions apis/firestore/v1alpha1/document_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import (
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var FirestoreDocumentGVK = GroupVersion.WithKind("FirestoreDocument")

// FirestoreDocumentSpec defines the desired state of FirestoreDocument
// +kcc:spec:proto=google.firestore.v1.Document
type FirestoreDocumentSpec struct {
// The FirestoreDocument name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

// // The resource name of the document, for example
// // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
// // +kcc:proto:field=google.firestore.v1.Document.name
// Name *string `json:"name,omitempty"`

// Fields holds the field values; values follow JSON typing conventions.
Fields map[string]string `json:"fields,omitempty"`
}

// FirestoreDocumentStatus defines the config connector machine state of FirestoreDocument
type FirestoreDocumentStatus struct {
/* Conditions represent the latest available observations of the
object's current state. */
Conditions []v1alpha1.Condition `json:"conditions,omitempty"`

// 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.
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`

// A unique specifier for the FirestoreDocument resource in GCP.
ExternalRef *string `json:"externalRef,omitempty"`

// ObservedState is the state of the resource as most recently observed in GCP.
ObservedState *FirestoreDocumentObservedState `json:"observedState,omitempty"`
}

// FirestoreDocumentObservedState is the state of the FirestoreDocument resource as most recently observed in GCP.
// +kcc:observedstate:proto=google.firestore.v1.Document
type FirestoreDocumentObservedState struct {
// Output only. The time at which the document was created.
//
// This value increases monotonically when a document is deleted then
// recreated. It can also be compared to values from other documents and
// the `read_time` of a query.
// +kcc:proto:field=google.firestore.v1.Document.create_time
CreateTime *string `json:"createTime,omitempty"`

// Output only. The time at which the document was last changed.
//
// This value is initially set to the `create_time` then increases
// monotonically with each change to the document. It can also be
// compared to values from other documents and the `read_time` of a query.
// +kcc:proto:field=google.firestore.v1.Document.update_time
UpdateTime *string `json:"updateTime,omitempty"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=gcp,shortName=gcpfirestoredocument;gcpfirestoredocuments
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true"
// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date"
// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded"
// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'"
// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'"

// FirestoreDocument is the Schema for the FirestoreDocument API
// +k8s:openapi-gen=true
type FirestoreDocument struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +required
Spec FirestoreDocumentSpec `json:"spec,omitempty"`
Status FirestoreDocumentStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FirestoreDocumentList contains a list of FirestoreDocument
type FirestoreDocumentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FirestoreDocument `json:"items"`
}

func init() {
SchemeBuilder.Register(&FirestoreDocument{}, &FirestoreDocumentList{})
}
10 changes: 6 additions & 4 deletions apis/firestore/v1alpha1/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.


set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd ${REPO_ROOT}/dev/tools/controllerbuilder

go run . generate-types \
go run . generate-types \
--service google.firestore.admin.v1 \
--api-version firestore.cnrm.cloud.google.com/v1alpha1 \
--resource FirestoreDocument:google.firestore.v1.Document \
--resource FirestoreDatabaseBackupSchedule:BackupSchedule \
--resource FirestoreField:Field

go run . generate-mapper \
--multiversion \
--service google.firestore.admin.v1 \
--service google.firestore.v1 \
--api-version firestore.cnrm.cloud.google.com/v1alpha1


cd ${REPO_ROOT}

dev/tasks/generate-crds

go run -mod=readonly golang.org/x/tools/cmd/goimports@latest -w pkg/controller/direct/firestore/
go run -mod=readonly golang.org/x/tools/cmd/goimports@latest -w pkg/controller/direct/firestore/
Loading
Loading