Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#2264 from GoogleCloudPlatform/…
Browse files Browse the repository at this point in the history
…acpana/dataform-direct-apis

chore: add DataformRepository apis
  • Loading branch information
google-oss-prow[bot] authored Jul 11, 2024
2 parents fbe4d73 + c00c822 commit 9140424
Show file tree
Hide file tree
Showing 6 changed files with 371 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apis/dataform/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.dataform.v1beta1

package v1alpha1
40 changes: 40 additions & 0 deletions apis/dataform/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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 contains API Schema definitions for the dataform v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=dataform.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: "dataform.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

GroupVersionKind = schema.GroupVersionKind{
Group: GroupVersion.Group,
Version: GroupVersion.Version,
Kind: "DataformRepository",
}
)
114 changes: 114 additions & 0 deletions apis/dataform/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// 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 (
refv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1"
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)


type RepositoryGitRemoteSettings struct {
/* The name of the Secret Manager secret version to use as an authentication token for Git operations. Must be in the format projects/* /secrets/* /versions/*. */
AuthenticationTokenSecretVersion string `json:"authenticationTokenSecretVersion"`

/* The Git remote's default branch name. */
DefaultBranch string `json:"defaultBranch"`

/* Indicates the status of the Git access token. https://cloud.google.com/dataform/reference/rest/v1beta1/projects.locations.repositories#TokenStatus. */
// +optional
TokenStatus *string `json:"tokenStatus,omitempty"`

/* The Git remote's URL. */
Url string `json:"url"`
}

type RepositoryWorkspaceCompilationOverrides struct {
/* Optional. The default database (Google Cloud project ID). */
// +optional
DefaultDatabase *string `json:"defaultDatabase,omitempty"`

/* Optional. The suffix that should be appended to all schema (BigQuery dataset ID) names. */
// +optional
SchemaSuffix *string `json:"schemaSuffix,omitempty"`

/* Optional. The prefix that should be prepended to all table names. */
// +optional
TablePrefix *string `json:"tablePrefix,omitempty"`
}

type DataformRepositorySpec struct {
/* Optional. If set, configures this repository to be linked to a Git remote. */
// +optional
GitRemoteSettings *RepositoryGitRemoteSettings `json:"gitRemoteSettings,omitempty"`

/* The project that this resource belongs to. */
// +required
ProjectRef *refv1beta1.ProjectRef `json:"projectRef"`

/* Immutable. A reference to the region. */
Region string `json:"region"`

/* Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */
// +optional
ResourceID *string `json:"resourceID,omitempty"`

/* Optional. If set, fields of workspaceCompilationOverrides override the default compilation settings that are specified in dataform.json when creating workspace-scoped compilation results. */
// +optional
WorkspaceCompilationOverrides *RepositoryWorkspaceCompilationOverrides `json:"workspaceCompilationOverrides,omitempty"`
}

type DataformRepositoryStatus struct {
/* Conditions represent the latest available observations of the
DataformRepository'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"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=gcp,shortName=gcpdataformrepository;gcpdataformrepositories
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=alpha";"cnrm.cloud.google.com/system=true";"cnrm.cloud.google.com/tf2crd=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'"

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

Spec DataformRepositorySpec `json:"spec,omitempty"`
Status DataformRepositoryStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// DataformRepositoryList contains a list of DataformRepository
type DataformRepositoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DataformRepository `json:"items"`
}

func init() {
SchemeBuilder.Register(&DataformRepository{}, &DataformRepositoryList{})
}
180 changes: 180 additions & 0 deletions apis/dataform/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions dev/tasks/generate-crds
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,28 @@ go run ./scripts/crd-tools reflow-descriptions --dir apis/config/crd/

# Copy generated CRDs to apis/config/crd/
# The crds directory is generated only as part of the release (currently)

# excluded_resources are resources that are under development for a direct conversion
# we don't modify the CRD just yet for those but will in the future
excluded_resources=("dataformrepositorie")

cd ${REPO_ROOT}
cd apis/config/crd/
for file in *.yaml; do
excluded=false

for substring in "${excluded_resources[@]}"; do
if [[ "$file" == *"$substring"* ]]; then
excluded=true
break
fi
done

if [ "$excluded" = true ]; then
echo "Skipping $file as its CRD conversion is excluded for now"
continue
fi

base_name=$(echo "$file" | sed 's/.yaml$//g')
domain=$(echo "$base_name" | cut -d'_' -f1)
resource=$(echo "$base_name" | cut -d'_' -f2)
Expand Down
1 change: 1 addition & 0 deletions dev/tools/proto-to-mapper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ generate-pb: install-protoc-linux
./third_party/googleapis/google/monitoring/v3/*.proto \
./third_party/googleapis/google/monitoring/dashboard/v1/*.proto \
./third_party/googleapis/google/devtools/cloudbuild/*/*.proto \
./third_party/googleapis/google/cloud/dataform/*/*.proto \
-o build/googleapis.pb

install-protoc-linux:
Expand Down

0 comments on commit 9140424

Please sign in to comment.