Skip to content

Commit

Permalink
WIP: Generate types for FirestoreDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvigil committed Aug 28, 2024
1 parent 1d4eebe commit 81de453
Show file tree
Hide file tree
Showing 6 changed files with 481 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apis/firestore/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2024 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.

// +kcc:proto=google.firestore.admin.v1
package v1alpha1
89 changes: 89 additions & 0 deletions apis/firestore/v1alpha1/firestoredatabase_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2024 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 FirestoreDatabaseGVK = GroupVersion.WithKind("FirestoreDatabase")

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// FirestoreDatabaseSpec defines the desired state of FirestoreDatabase
// +kcc:proto=google.firestore.admin.v1.Database
type FirestoreDatabaseSpec struct {
// The FirestoreDatabase name. If not given, the metadata.name will be used.
// + optional
ResourceID *string `json:"resourceID,omitempty"`
}

// FirestoreDatabaseStatus defines the config connector machine state of FirestoreDatabase
type FirestoreDatabaseStatus 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.
// +optional
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`

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

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

// FirestoreDatabaseSpec defines the desired state of FirestoreDatabase
// +kcc:proto=google.firestore.admin.v1.Database
type FirestoreDatabaseObservedState struct {
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=gcp
// +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'"

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

Spec FirestoreDatabaseSpec `json:"spec,omitempty"`
Status FirestoreDatabaseStatus `json:"status,omitempty"`
}

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

func init() {
SchemeBuilder.Register(&FirestoreDatabase{}, &FirestoreDatabaseList{})

Check failure on line 88 in apis/firestore/v1alpha1/firestoredatabase_types.go

View workflow job for this annotation

GitHub Actions / lint

cannot use &FirestoreDatabase{} (value of type *FirestoreDatabase) as "k8s.io/apimachinery/pkg/runtime".Object value in argument to SchemeBuilder.Register: *FirestoreDatabase does not implement "k8s.io/apimachinery/pkg/runtime".Object (missing method DeepCopyObject)

Check failure on line 88 in apis/firestore/v1alpha1/firestoredatabase_types.go

View workflow job for this annotation

GitHub Actions / lint

cannot use &FirestoreDatabaseList{} (value of type *FirestoreDatabaseList) as "k8s.io/apimachinery/pkg/runtime".Object value in argument to SchemeBuilder.Register: *FirestoreDatabaseList does not implement "k8s.io/apimachinery/pkg/runtime".Object (missing method DeepCopyObject) (typecheck)
}
33 changes: 33 additions & 0 deletions apis/firestore/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 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.

// +kubebuilder:object:generate=true
// +groupName=firestore.cnrm.cloud.google.com
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "firestore.cnrm.cloud.google.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
Loading

0 comments on commit 81de453

Please sign in to comment.