diff --git a/apis/discoveryengine/v1alpha1/datastore_reference.go b/apis/discoveryengine/v1alpha1/datastore_reference.go new file mode 100644 index 0000000000..25fde3c35d --- /dev/null +++ b/apis/discoveryengine/v1alpha1/datastore_reference.go @@ -0,0 +1,187 @@ +// 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 ( + "context" + "fmt" + "strings" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &DiscoveryEngineDataStoreRef{} + +// DiscoveryEngineDataStoreRef defines the resource reference to DiscoveryEngineDataStore, which "External" field +// holds the GCP identifier for the KRM object. +type DiscoveryEngineDataStoreRef struct { + // A reference to an externally managed DiscoveryEngineDataStore resource. + // Should be in the format "projects//locations//datastores/". + External string `json:"external,omitempty"` + + // The name of a DiscoveryEngineDataStore resource. + Name string `json:"name,omitempty"` + + // The namespace of a DiscoveryEngineDataStore resource. + Namespace string `json:"namespace,omitempty"` + + parent *DiscoveryEngineDataStoreParent +} + +// NormalizedExternal provision the "External" value for other resource that depends on DiscoveryEngineDataStore. +// If the "External" is given in the other resource's spec.DiscoveryEngineDataStoreRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual DiscoveryEngineDataStore object from the cluster. +func (r *DiscoveryEngineDataStoreRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", DiscoveryEngineDataStoreGVK.Kind) + } + // From given External + if r.External != "" { + if _, _, err := parseDiscoveryEngineDataStoreExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(DiscoveryEngineDataStoreGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", DiscoveryEngineDataStoreGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} + +// New builds a DiscoveryEngineDataStoreRef from the Config Connector DiscoveryEngineDataStore object. +func NewDiscoveryEngineDataStoreRef(ctx context.Context, reader client.Reader, obj *DiscoveryEngineDataStore) (*DiscoveryEngineDataStoreRef, error) { + id := &DiscoveryEngineDataStoreRef{} + + // Get Parent + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + if err != nil { + return nil, err + } + projectID := projectRef.ProjectID + if projectID == "" { + return nil, fmt.Errorf("cannot resolve project") + } + location := obj.Spec.Location + id.parent = &DiscoveryEngineDataStoreParent{ProjectID: projectID, Location: location} + + // Get desired ID + resourceID := valueOf(obj.Spec.ResourceID) + if resourceID == "" { + resourceID = obj.GetName() + } + if resourceID == "" { + return nil, fmt.Errorf("cannot resolve resource ID") + } + + // Use approved External + externalRef := valueOf(obj.Status.ExternalRef) + if externalRef == "" { + id.External = asDiscoveryEngineDataStoreExternal(id.parent, resourceID) + return id, nil + } + + // Validate desired with actual + actualParent, actualResourceID, err := parseDiscoveryEngineDataStoreExternal(externalRef) + if err != nil { + return nil, err + } + if actualParent.ProjectID != projectID { + return nil, fmt.Errorf("spec.projectRef changed, expect %s, got %s", actualParent.ProjectID, projectID) + } + if actualParent.Location != location { + return nil, fmt.Errorf("spec.location changed, expect %s, got %s", actualParent.Location, location) + } + if actualResourceID != resourceID { + return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s", + resourceID, actualResourceID) + } + id.External = externalRef + id.parent = &DiscoveryEngineDataStoreParent{ProjectID: projectID, Location: location} + return id, nil +} + +func (r *DiscoveryEngineDataStoreRef) Parent() (*DiscoveryEngineDataStoreParent, error) { + if r.parent != nil { + return r.parent, nil + } + if r.External != "" { + parent, _, err := parseDiscoveryEngineDataStoreExternal(r.External) + if err != nil { + return nil, err + } + return parent, nil + } + return nil, fmt.Errorf("DiscoveryEngineDataStoreRef not initialized from `NewDiscoveryEngineDataStoreRef` or `NormalizedExternal`") +} + +type DiscoveryEngineDataStoreParent struct { + ProjectID string + Location string +} + +func (p *DiscoveryEngineDataStoreParent) String() string { + return "projects/" + p.ProjectID + "/locations/" + p.Location +} + +func asDiscoveryEngineDataStoreExternal(parent *DiscoveryEngineDataStoreParent, resourceID string) (external string) { + return parent.String() + "/datastores/" + resourceID +} + +func parseDiscoveryEngineDataStoreExternal(external string) (parent *DiscoveryEngineDataStoreParent, resourceID string, err error) { + external = strings.TrimPrefix(external, "/") + tokens := strings.Split(external, "/") + if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "datastore" { + return nil, "", fmt.Errorf("format of DiscoveryEngineDataStore external=%q was not known (use projects//locations//datastores/)", external) + } + parent = &DiscoveryEngineDataStoreParent{ + ProjectID: tokens[1], + Location: tokens[3], + } + resourceID = tokens[5] + return parent, resourceID, nil +} + +func valueOf[T any](t *T) T { + var zeroVal T + if t == nil { + return zeroVal + } + return *t +} diff --git a/apis/discoveryengine/v1alpha1/discoveryenginedatastore_types.go b/apis/discoveryengine/v1alpha1/discoveryenginedatastore_types.go new file mode 100644 index 0000000000..f9bb95f89d --- /dev/null +++ b/apis/discoveryengine/v1alpha1/discoveryenginedatastore_types.go @@ -0,0 +1,139 @@ +// 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 ( + refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var DiscoveryEngineDataStoreGVK = GroupVersion.WithKind("DiscoveryEngineDataStore") + +// DiscoveryEngineDataStoreSpec defines the desired state of DiscoveryEngineDataStore +// +kcc:proto=google.cloud.discoveryengine.v1.DataStore +type DiscoveryEngineDataStoreSpec struct { + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" + // Immutable. + // The DiscoveryEngineDataStore name. If not given, the metadata.name will be used. + ResourceID *string `json:"resourceID,omitempty"` + + // Required. The data store display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + DisplayName *string `json:"displayName,omitempty"` + + // Immutable. The industry vertical that the data store registers. + IndustryVertical *string `json:"industryVertical,omitempty"` + + // The solutions that the data store enrolls. Available solutions for each + // [industry_vertical][google.cloud.discoveryengine.v1.DataStore.industry_vertical]: + // + // * `MEDIA`: `SOLUTION_TYPE_RECOMMENDATION` and `SOLUTION_TYPE_SEARCH`. + // * `SITE_SEARCH`: `SOLUTION_TYPE_SEARCH` is automatically enrolled. Other + // solutions cannot be enrolled. + SolutionTypes []string `json:"solutionTypes,omitempty"` + + // Immutable. The content config of the data store. If this field is unset, + // the server behavior defaults to + // [ContentConfig.NO_CONTENT][google.cloud.discoveryengine.v1.DataStore.ContentConfig.NO_CONTENT]. + ContentConfig *string `json:"contentConfig,omitempty"` + + // Config to store data store type configuration for workspace data. This + // must be set when + // [DataStore.content_config][google.cloud.discoveryengine.v1.DataStore.content_config] + // is set as + // [DataStore.ContentConfig.GOOGLE_WORKSPACE][google.cloud.discoveryengine.v1.DataStore.ContentConfig.GOOGLE_WORKSPACE]. + WorkspaceConfig *WorkspaceConfig `json:"workspaceConfig,omitempty"` + + /* NOTYET: this includes a map[string]object which is difficult to map to KRM + // Configuration for Document understanding and enrichment. + DocumentProcessingConfig *DocumentProcessingConfig `json:"documentProcessingConfig,omitempty"` + */ + + /* The ID of the project in which the resource belongs.*/ + ProjectRef *refs.ProjectRef `json:"projectRef"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Location field is immutable" + // Immutable. The location for the resource. + Location string `json:"location"` +} + +// DiscoveryEngineDataStoreStatus defines the config connector machine state of DiscoveryEngineDataStore +type DiscoveryEngineDataStoreStatus 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 DiscoveryEngineDataStore resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + // ObservedState is the state of the resource as most recently observed in GCP. + ObservedState *DiscoveryEngineDataStoreObservedState `json:"observedState,omitempty"` +} + +// DiscoveryEngineDataStoreObservedState is the state of the DiscoveryEngineDataStore resource as most recently observed in GCP. +// +kcc:proto=google.cloud.discoveryengine.v1.DataStore +type DiscoveryEngineDataStoreObservedState struct { + // Output only. The id of the default + // [Schema][google.cloud.discoveryengine.v1.Schema] asscociated to this data + // store. + DefaultSchemaID *string `json:"defaultSchemaID,omitempty"` + + // Output only. Timestamp the + // [DataStore][google.cloud.discoveryengine.v1.DataStore] was created at. + CreateTime *string `json:"createTime,omitempty"` + + // Output only. Data size estimation for billing. + BillingEstimation *DataStore_BillingEstimation `json:"billingEstimation,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// TODO(user): make sure the pluralizaiton below is correct +// +kubebuilder:resource:categories=gcp,shortName=gcpdiscoveryenginedatastore;gcpdiscoveryenginedatastores +// +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'" + +// DiscoveryEngineDataStore is the Schema for the DiscoveryEngineDataStore API +// +k8s:openapi-gen=true +type DiscoveryEngineDataStore struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +required + Spec DiscoveryEngineDataStoreSpec `json:"spec,omitempty"` + Status DiscoveryEngineDataStoreStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// DiscoveryEngineDataStoreList contains a list of DiscoveryEngineDataStore +type DiscoveryEngineDataStoreList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DiscoveryEngineDataStore `json:"items"` +} + +func init() { + SchemeBuilder.Register(&DiscoveryEngineDataStore{}, &DiscoveryEngineDataStoreList{}) +} diff --git a/apis/discoveryengine/v1alpha1/doc.go b/apis/discoveryengine/v1alpha1/doc.go new file mode 100644 index 0000000000..549203dc1a --- /dev/null +++ b/apis/discoveryengine/v1alpha1/doc.go @@ -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.cloud.discoveryengine.v1 +package v1alpha1 diff --git a/apis/discoveryengine/v1alpha1/groupversion_info.go b/apis/discoveryengine/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..b39fe0b24a --- /dev/null +++ b/apis/discoveryengine/v1alpha1/groupversion_info.go @@ -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=discoveryengine.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: "discoveryengine.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 +) diff --git a/apis/discoveryengine/v1alpha1/types.generated.go b/apis/discoveryengine/v1alpha1/types.generated.go new file mode 100644 index 0000000000..77fd262e82 --- /dev/null +++ b/apis/discoveryengine/v1alpha1/types.generated.go @@ -0,0 +1,144 @@ +// 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 + +// +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation +type DataStore_BillingEstimation struct { + // Data size for structured data in terms of bytes. + StructuredDataSize *int64 `json:"structuredDataSize,omitempty"` + + // Data size for unstructured data in terms of bytes. + UnstructuredDataSize *int64 `json:"unstructuredDataSize,omitempty"` + + // Data size for websites in terms of bytes. + WebsiteDataSize *int64 `json:"websiteDataSize,omitempty"` + + // Last updated timestamp for structured data. + StructuredDataUpdateTime *string `json:"structuredDataUpdateTime,omitempty"` + + // Last updated timestamp for unstructured data. + UnstructuredDataUpdateTime *string `json:"unstructuredDataUpdateTime,omitempty"` + + // Last updated timestamp for websites. + WebsiteDataUpdateTime *string `json:"websiteDataUpdateTime,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig +type DocumentProcessingConfig struct { + // The full resource name of the Document Processing Config. + // Format: + // `projects/*/locations/*/collections/*/dataStores/*/documentProcessingConfig`. + Name *string `json:"name,omitempty"` + + // Whether chunking mode is enabled. + ChunkingConfig *DocumentProcessingConfig_ChunkingConfig `json:"chunkingConfig,omitempty"` + + // Configurations for default Document parser. + // If not specified, we will configure it as default DigitalParsingConfig, and + // the default parsing config will be applied to all file types for Document + // parsing. + DefaultParsingConfig *DocumentProcessingConfig_ParsingConfig `json:"defaultParsingConfig,omitempty"` + + // TODO: map type string message for parsing_config_overrides + +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig +type DocumentProcessingConfig_ChunkingConfig struct { + // Configuration for the layout based chunking. + LayoutBasedChunkingConfig *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig `json:"layoutBasedChunkingConfig,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig.LayoutBasedChunkingConfig +type DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig struct { + // The token size limit for each chunk. + // + // Supported values: 100-500 (inclusive). + // Default value: 500. + ChunkSize *int32 `json:"chunkSize,omitempty"` + + // Whether to include appending different levels of headings to chunks + // from the middle of the document to prevent context loss. + // + // Default value: False. + IncludeAncestorHeadings *bool `json:"includeAncestorHeadings,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig +type DocumentProcessingConfig_ParsingConfig struct { + // Configurations applied to digital parser. + DigitalParsingConfig *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig `json:"digitalParsingConfig,omitempty"` + + // Configurations applied to OCR parser. Currently it only applies to + // PDFs. + OcrParsingConfig *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig `json:"ocrParsingConfig,omitempty"` + + // Configurations applied to layout parser. + LayoutParsingConfig *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig `json:"layoutParsingConfig,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.DigitalParsingConfig +type DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig struct { +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.LayoutParsingConfig +type DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig struct { +} + +// +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.OcrParsingConfig +type DocumentProcessingConfig_ParsingConfig_OcrParsingConfig struct { + // [DEPRECATED] This field is deprecated. To use the additional enhanced + // document elements processing, please switch to `layout_parsing_config`. + EnhancedDocumentElements []string `json:"enhancedDocumentElements,omitempty"` + + // If true, will use native text instead of OCR text on pages containing + // native text. + UseNativeText *bool `json:"useNativeText,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.Schema +type Schema struct { + // The structured representation of the schema. + StructSchema map[string]string `json:"structSchema,omitempty"` + + // The JSON representation of the schema. + JsonSchema *string `json:"jsonSchema,omitempty"` + + // Immutable. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + // + // This field must be a UTF-8 encoded string with a length limit of 1024 + // characters. + Name *string `json:"name,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig +type WorkspaceConfig struct { + // The Google Workspace data source. + Type *string `json:"type,omitempty"` + + // Obfuscated Dasher customer ID. + DasherCustomerID *string `json:"dasherCustomerID,omitempty"` + + // Optional. The super admin service account for the workspace that will be + // used for access token generation. For now we only use it for Native Google + // Drive connector data ingestion. + SuperAdminServiceAccount *string `json:"superAdminServiceAccount,omitempty"` + + // Optional. The super admin email address for the workspace that will be used + // for access token generation. For now we only use it for Native Google Drive + // connector data ingestion. + SuperAdminEmailAddress *string `json:"superAdminEmailAddress,omitempty"` +} diff --git a/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..f881ca6a1f --- /dev/null +++ b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,506 @@ +//go:build !ignore_autogenerated + +// Copyright 2020 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. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + k8sv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DataStore_BillingEstimation) DeepCopyInto(out *DataStore_BillingEstimation) { + *out = *in + if in.StructuredDataSize != nil { + in, out := &in.StructuredDataSize, &out.StructuredDataSize + *out = new(int64) + **out = **in + } + if in.UnstructuredDataSize != nil { + in, out := &in.UnstructuredDataSize, &out.UnstructuredDataSize + *out = new(int64) + **out = **in + } + if in.WebsiteDataSize != nil { + in, out := &in.WebsiteDataSize, &out.WebsiteDataSize + *out = new(int64) + **out = **in + } + if in.StructuredDataUpdateTime != nil { + in, out := &in.StructuredDataUpdateTime, &out.StructuredDataUpdateTime + *out = new(string) + **out = **in + } + if in.UnstructuredDataUpdateTime != nil { + in, out := &in.UnstructuredDataUpdateTime, &out.UnstructuredDataUpdateTime + *out = new(string) + **out = **in + } + if in.WebsiteDataUpdateTime != nil { + in, out := &in.WebsiteDataUpdateTime, &out.WebsiteDataUpdateTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataStore_BillingEstimation. +func (in *DataStore_BillingEstimation) DeepCopy() *DataStore_BillingEstimation { + if in == nil { + return nil + } + out := new(DataStore_BillingEstimation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStore) DeepCopyInto(out *DiscoveryEngineDataStore) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStore. +func (in *DiscoveryEngineDataStore) DeepCopy() *DiscoveryEngineDataStore { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStore) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DiscoveryEngineDataStore) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreList) DeepCopyInto(out *DiscoveryEngineDataStoreList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DiscoveryEngineDataStore, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreList. +func (in *DiscoveryEngineDataStoreList) DeepCopy() *DiscoveryEngineDataStoreList { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DiscoveryEngineDataStoreList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreObservedState) DeepCopyInto(out *DiscoveryEngineDataStoreObservedState) { + *out = *in + if in.DefaultSchemaID != nil { + in, out := &in.DefaultSchemaID, &out.DefaultSchemaID + *out = new(string) + **out = **in + } + if in.CreateTime != nil { + in, out := &in.CreateTime, &out.CreateTime + *out = new(string) + **out = **in + } + if in.BillingEstimation != nil { + in, out := &in.BillingEstimation, &out.BillingEstimation + *out = new(DataStore_BillingEstimation) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreObservedState. +func (in *DiscoveryEngineDataStoreObservedState) DeepCopy() *DiscoveryEngineDataStoreObservedState { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreParent) DeepCopyInto(out *DiscoveryEngineDataStoreParent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreParent. +func (in *DiscoveryEngineDataStoreParent) DeepCopy() *DiscoveryEngineDataStoreParent { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreParent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreRef) DeepCopyInto(out *DiscoveryEngineDataStoreRef) { + *out = *in + if in.parent != nil { + in, out := &in.parent, &out.parent + *out = new(DiscoveryEngineDataStoreParent) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreRef. +func (in *DiscoveryEngineDataStoreRef) DeepCopy() *DiscoveryEngineDataStoreRef { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreSpec) DeepCopyInto(out *DiscoveryEngineDataStoreSpec) { + *out = *in + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.DisplayName != nil { + in, out := &in.DisplayName, &out.DisplayName + *out = new(string) + **out = **in + } + if in.IndustryVertical != nil { + in, out := &in.IndustryVertical, &out.IndustryVertical + *out = new(string) + **out = **in + } + if in.SolutionTypes != nil { + in, out := &in.SolutionTypes, &out.SolutionTypes + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ContentConfig != nil { + in, out := &in.ContentConfig, &out.ContentConfig + *out = new(string) + **out = **in + } + if in.WorkspaceConfig != nil { + in, out := &in.WorkspaceConfig, &out.WorkspaceConfig + *out = new(WorkspaceConfig) + (*in).DeepCopyInto(*out) + } + if in.ProjectRef != nil { + in, out := &in.ProjectRef, &out.ProjectRef + *out = new(v1beta1.ProjectRef) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreSpec. +func (in *DiscoveryEngineDataStoreSpec) DeepCopy() *DiscoveryEngineDataStoreSpec { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreStatus) DeepCopyInto(out *DiscoveryEngineDataStoreStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]k8sv1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + if in.ExternalRef != nil { + in, out := &in.ExternalRef, &out.ExternalRef + *out = new(string) + **out = **in + } + if in.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(DiscoveryEngineDataStoreObservedState) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreStatus. +func (in *DiscoveryEngineDataStoreStatus) DeepCopy() *DiscoveryEngineDataStoreStatus { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig) DeepCopyInto(out *DocumentProcessingConfig) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.ChunkingConfig != nil { + in, out := &in.ChunkingConfig, &out.ChunkingConfig + *out = new(DocumentProcessingConfig_ChunkingConfig) + (*in).DeepCopyInto(*out) + } + if in.DefaultParsingConfig != nil { + in, out := &in.DefaultParsingConfig, &out.DefaultParsingConfig + *out = new(DocumentProcessingConfig_ParsingConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig. +func (in *DocumentProcessingConfig) DeepCopy() *DocumentProcessingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ChunkingConfig) DeepCopyInto(out *DocumentProcessingConfig_ChunkingConfig) { + *out = *in + if in.LayoutBasedChunkingConfig != nil { + in, out := &in.LayoutBasedChunkingConfig, &out.LayoutBasedChunkingConfig + *out = new(DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ChunkingConfig. +func (in *DocumentProcessingConfig_ChunkingConfig) DeepCopy() *DocumentProcessingConfig_ChunkingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ChunkingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig) DeepCopyInto(out *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig) { + *out = *in + if in.ChunkSize != nil { + in, out := &in.ChunkSize, &out.ChunkSize + *out = new(int32) + **out = **in + } + if in.IncludeAncestorHeadings != nil { + in, out := &in.IncludeAncestorHeadings, &out.IncludeAncestorHeadings + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig. +func (in *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig) DeepCopy() *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ParsingConfig) DeepCopyInto(out *DocumentProcessingConfig_ParsingConfig) { + *out = *in + if in.DigitalParsingConfig != nil { + in, out := &in.DigitalParsingConfig, &out.DigitalParsingConfig + *out = new(DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig) + **out = **in + } + if in.OcrParsingConfig != nil { + in, out := &in.OcrParsingConfig, &out.OcrParsingConfig + *out = new(DocumentProcessingConfig_ParsingConfig_OcrParsingConfig) + (*in).DeepCopyInto(*out) + } + if in.LayoutParsingConfig != nil { + in, out := &in.LayoutParsingConfig, &out.LayoutParsingConfig + *out = new(DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ParsingConfig. +func (in *DocumentProcessingConfig_ParsingConfig) DeepCopy() *DocumentProcessingConfig_ParsingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ParsingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig) DeepCopyInto(out *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig. +func (in *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig) DeepCopy() *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig) DeepCopyInto(out *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig. +func (in *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig) DeepCopy() *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig) DeepCopyInto(out *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig) { + *out = *in + if in.EnhancedDocumentElements != nil { + in, out := &in.EnhancedDocumentElements, &out.EnhancedDocumentElements + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.UseNativeText != nil { + in, out := &in.UseNativeText, &out.UseNativeText + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocumentProcessingConfig_ParsingConfig_OcrParsingConfig. +func (in *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig) DeepCopy() *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig { + if in == nil { + return nil + } + out := new(DocumentProcessingConfig_ParsingConfig_OcrParsingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Schema) DeepCopyInto(out *Schema) { + *out = *in + if in.StructSchema != nil { + in, out := &in.StructSchema, &out.StructSchema + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.JsonSchema != nil { + in, out := &in.JsonSchema, &out.JsonSchema + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Schema. +func (in *Schema) DeepCopy() *Schema { + if in == nil { + return nil + } + out := new(Schema) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WorkspaceConfig) DeepCopyInto(out *WorkspaceConfig) { + *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } + if in.DasherCustomerID != nil { + in, out := &in.DasherCustomerID, &out.DasherCustomerID + *out = new(string) + **out = **in + } + if in.SuperAdminServiceAccount != nil { + in, out := &in.SuperAdminServiceAccount, &out.SuperAdminServiceAccount + *out = new(string) + **out = **in + } + if in.SuperAdminEmailAddress != nil { + in, out := &in.SuperAdminEmailAddress, &out.SuperAdminEmailAddress + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceConfig. +func (in *WorkspaceConfig) DeepCopy() *WorkspaceConfig { + if in == nil { + return nil + } + out := new(WorkspaceConfig) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastores.discoveryengine.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastores.discoveryengine.cnrm.cloud.google.com.yaml new file mode 100644 index 0000000000..e40eaa2775 --- /dev/null +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastores.discoveryengine.cnrm.cloud.google.com.yaml @@ -0,0 +1,248 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cnrm.cloud.google.com/version: 0.0.0-dev + creationTimestamp: null + labels: + cnrm.cloud.google.com/managed-by-kcc: "true" + cnrm.cloud.google.com/system: "true" + name: discoveryenginedatastores.discoveryengine.cnrm.cloud.google.com +spec: + group: discoveryengine.cnrm.cloud.google.com + names: + categories: + - gcp + kind: DiscoveryEngineDataStore + listKind: DiscoveryEngineDataStoreList + plural: discoveryenginedatastores + shortNames: + - gcpdiscoveryenginedatastore + - gcpdiscoveryenginedatastores + singular: discoveryenginedatastore + preserveUnknownFields: false + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: When 'True', the most recent reconcile of the resource succeeded + jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + - description: The reason for the value in 'Ready' + jsonPath: .status.conditions[?(@.type=='Ready')].reason + name: Status + type: string + - description: The last transition time for the value in 'Status' + jsonPath: .status.conditions[?(@.type=='Ready')].lastTransitionTime + name: Status Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: DiscoveryEngineDataStore is the Schema for the DiscoveryEngineDataStore + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: DiscoveryEngineDataStoreSpec defines the desired state of + DiscoveryEngineDataStore + properties: + contentConfig: + description: Immutable. The content config of the data store. If this + field is unset, the server behavior defaults to [ContentConfig.NO_CONTENT][google.cloud.discoveryengine.v1.DataStore.ContentConfig.NO_CONTENT]. + type: string + displayName: + description: |- + Required. The data store display name. + + This field must be a UTF-8 encoded string with a length limit of 128 + characters. Otherwise, an INVALID_ARGUMENT error is returned. + type: string + industryVertical: + description: Immutable. The industry vertical that the data store + registers. + type: string + location: + description: Immutable. The location for the resource. + type: string + x-kubernetes-validations: + - message: Location field is immutable + rule: self == oldSelf + projectRef: + description: The ID of the project in which the resource belongs. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The `projectID` field of a project, when not managed + by Config Connector. + type: string + kind: + description: The kind of the Project resource; optional but must + be `Project` if provided. + type: string + name: + description: The `name` field of a `Project` resource. + type: string + namespace: + description: The `namespace` field of a `Project` resource. + type: string + type: object + resourceID: + description: Immutable. The DiscoveryEngineDataStore name. If not + given, the metadata.name will be used. + type: string + x-kubernetes-validations: + - message: ResourceID field is immutable + rule: self == oldSelf + solutionTypes: + description: |- + The solutions that the data store enrolls. Available solutions for each + [industry_vertical][google.cloud.discoveryengine.v1.DataStore.industry_vertical]: + + * `MEDIA`: `SOLUTION_TYPE_RECOMMENDATION` and `SOLUTION_TYPE_SEARCH`. + * `SITE_SEARCH`: `SOLUTION_TYPE_SEARCH` is automatically enrolled. Other + solutions cannot be enrolled. + items: + type: string + type: array + workspaceConfig: + description: Config to store data store type configuration for workspace + data. This must be set when [DataStore.content_config][google.cloud.discoveryengine.v1.DataStore.content_config] + is set as [DataStore.ContentConfig.GOOGLE_WORKSPACE][google.cloud.discoveryengine.v1.DataStore.ContentConfig.GOOGLE_WORKSPACE]. + properties: + dasherCustomerID: + description: Obfuscated Dasher customer ID. + type: string + superAdminEmailAddress: + description: Optional. The super admin email address for the workspace + that will be used for access token generation. For now we only + use it for Native Google Drive connector data ingestion. + type: string + superAdminServiceAccount: + description: Optional. The super admin service account for the + workspace that will be used for access token generation. For + now we only use it for Native Google Drive connector data ingestion. + type: string + type: + description: The Google Workspace data source. + type: string + type: object + required: + - location + - projectRef + type: object + status: + description: DiscoveryEngineDataStoreStatus defines the config connector + machine state of DiscoveryEngineDataStore + properties: + conditions: + description: Conditions represent the latest available observations + of the object's current state. + items: + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + type: string + message: + description: Human-readable message indicating details about + last transition. + type: string + reason: + description: Unique, one-word, CamelCase reason for the condition's + last transition. + type: string + status: + description: Status is the status of the condition. Can be True, + False, Unknown. + type: string + type: + description: Type is the type of the condition. + type: string + type: object + type: array + externalRef: + description: A unique specifier for the DiscoveryEngineDataStore resource + in GCP. + type: string + observedGeneration: + description: 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. + format: int64 + type: integer + observedState: + description: ObservedState is the state of the resource as most recently + observed in GCP. + properties: + billingEstimation: + description: Output only. Data size estimation for billing. + properties: + structuredDataSize: + description: Data size for structured data in terms of bytes. + format: int64 + type: integer + structuredDataUpdateTime: + description: Last updated timestamp for structured data. + type: string + unstructuredDataSize: + description: Data size for unstructured data in terms of bytes. + format: int64 + type: integer + unstructuredDataUpdateTime: + description: Last updated timestamp for unstructured data. + type: string + websiteDataSize: + description: Data size for websites in terms of bytes. + format: int64 + type: integer + websiteDataUpdateTime: + description: Last updated timestamp for websites. + type: string + type: object + createTime: + description: Output only. Timestamp the [DataStore][google.cloud.discoveryengine.v1.DataStore] + was created at. + type: string + defaultSchemaID: + description: Output only. The id of the default [Schema][google.cloud.discoveryengine.v1.Schema] + asscociated to this data store. + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/installbundle/components/clusterroles/cnrm_admin.yaml b/config/installbundle/components/clusterroles/cnrm_admin.yaml index 4cad889e9e..ab5dc378e4 100644 --- a/config/installbundle/components/clusterroles/cnrm_admin.yaml +++ b/config/installbundle/components/clusterroles/cnrm_admin.yaml @@ -511,6 +511,18 @@ rules: - update - patch - delete +- apiGroups: + - discoveryengine.cnrm.cloud.google.com + resources: + - '*' + verbs: + - get + - list + - watch + - create + - update + - patch + - delete - apiGroups: - dlp.cnrm.cloud.google.com resources: diff --git a/config/installbundle/components/clusterroles/cnrm_viewer.yaml b/config/installbundle/components/clusterroles/cnrm_viewer.yaml index cc22b00f3a..e6ebf47163 100644 --- a/config/installbundle/components/clusterroles/cnrm_viewer.yaml +++ b/config/installbundle/components/clusterroles/cnrm_viewer.yaml @@ -342,6 +342,14 @@ rules: - get - list - watch +- apiGroups: + - discoveryengine.cnrm.cloud.google.com + resources: + - '*' + verbs: + - get + - list + - watch - apiGroups: - dlp.cnrm.cloud.google.com resources: diff --git a/dev/tools/controllerbuilder/generate.sh b/dev/tools/controllerbuilder/generate.sh index b972441642..6cad3883a2 100755 --- a/dev/tools/controllerbuilder/generate.sh +++ b/dev/tools/controllerbuilder/generate.sh @@ -24,6 +24,27 @@ cd ${REPO_ROOT}/dev/tools/controllerbuilder APIS_DIR=${REPO_ROOT}/apis/ OUTPUT_MAPPER=${REPO_ROOT}/pkg/controller/direct/ +# DiscoveryEngine +go run . generate-types \ + --proto-source-path ../proto-to-mapper/build/googleapis.pb \ + --service google.cloud.discoveryengine.v1 \ + --api-version discoveryengine.cnrm.cloud.google.com/v1alpha1 \ + --output-api ${APIS_DIR} \ + --kind DiscoveryEngineDataStore \ + --proto-resource DataStore + +# go run . prompt --src-dir ~/kcc/k8s-config-connector --proto-dir ~/kcc/k8s-config-connector/dev/tools/proto-to-mapper/third_party/googleapis/ < 4 { count = 0 } - listVal := msg.Mutable(field).List() switch field.Kind() { case protoreflect.MessageKind: + listVal := msg.Mutable(field).List() for j := 0; j < count; j++ { el := listVal.AppendMutable() fillWithRandom0(t, randStream, el.Message()) } case protoreflect.StringKind: + listVal := msg.Mutable(field).List() for j := 0; j < count; j++ { s := randomString(randStream) listVal.Append(protoreflect.ValueOf(s)) } + case protoreflect.EnumKind: + listVal := msg.Mutable(field).List() + for j := 0; j < count; j++ { + enumDescriptor := field.Enum() + n := enumDescriptor.Values().Len() + val := enumDescriptor.Values().Get(randStream.Intn(n)) + listVal.Append(protoreflect.ValueOf(val.Number())) + } + default: t.Fatalf("unhandled field kind %v: %v", field.Kind(), field) } @@ -108,9 +118,20 @@ func fillWithRandom0(t *testing.T, randStream *rand.Rand, msg protoreflect.Messa case "string->message": if field.FullName() == "google.protobuf.Struct.fields" && field.MapValue().Message().FullName() == "google.protobuf.Value" { // currently this is converted to "map[string]string" in "BigQueryDataTransferConfig" - // TODO: fill in random strings + mapVal := msg.Mutable(field).Map() + for j := 0; j < count; j++ { + k := randomString(randStream) + v := randomString(randStream) + el := mapVal.Mutable(protoreflect.ValueOf(k).MapKey()).Message() + el.Set(el.Descriptor().Fields().ByName("string_value"), protoreflect.ValueOfString(v)) + } } else { - t.Fatalf("unhandled case for map kind %q: %v", mapType, field) + mapVal := msg.Mutable(field).Map() + for j := 0; j < count; j++ { + k := randomString(randStream) + el := mapVal.Mutable(protoreflect.ValueOf(k).MapKey()) + fillWithRandom0(t, randStream, el.Message()) + } } default: @@ -274,6 +295,15 @@ func Visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect. visitor.VisitPrimitive(path+"[]", el, setter) } + case protoreflect.EnumKind: + for j := 0; j < count; j++ { + el := listVal.Get(j) + setter := func(v protoreflect.Value) { + listVal.Set(j, v) + } + visitor.VisitPrimitive(path+"[]", el, setter) + } + default: klog.Fatalf("unhandled field kind %v: %v", field.Kind(), field) } @@ -304,9 +334,33 @@ func Visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect. visitor.VisitPrimitive(mapPath, val, setter) return true }) + case "string->message": + mapVal := msg.Mutable(field).Map() + setter := func(v protoreflect.Value) { + if v.IsValid() { + msg.Set(field, v) + } else { + msg.Clear(field) + } + } + visitor.VisitMap(path, mapVal, setter) + + // In case the value changes + mapVal = msg.Mutable(field).Map() + mapVal.Range(func(k protoreflect.MapKey, val protoreflect.Value) bool { + mapPath := path + "[" + k.String() + "]" + setter := func(v protoreflect.Value) { + mapVal.Set(k, v) + } + + v := mapVal.Get(k) + Visit(mapPath, v.Message(), setter, visitor) + + return true + }) default: - klog.Fatalf("unhandled map kind %q: %v", mapType, field) + klog.Fatalf("unhandled map kind in visitor %q: %v", mapType, field) } return true } @@ -328,6 +382,7 @@ func Visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect. protoreflect.Int64Kind, protoreflect.Uint64Kind, protoreflect.StringKind, + protoreflect.BytesKind, protoreflect.EnumKind: setter := func(v protoreflect.Value) { if v.IsValid() {