Skip to content

Commit

Permalink
Automated Config Connector import.
Browse files Browse the repository at this point in the history
  - 5689ec0ab0131c4d72874b08871ffedfce7c655c Add the PubSubSchema resource through TF by Config Connector Team <[email protected]>

GitOrigin-RevId: 5689ec0ab0131c4d72874b08871ffedfce7c655c
  • Loading branch information
Config Connector Team authored and copybara-github committed Jun 16, 2022
1 parent 61d0607 commit 7f2c8f4
Show file tree
Hide file tree
Showing 20 changed files with 1,142 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
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/stability-level: stable
cnrm.cloud.google.com/system: "true"
cnrm.cloud.google.com/tf2crd: "true"
name: pubsubschemas.pubsub.cnrm.cloud.google.com
spec:
group: pubsub.cnrm.cloud.google.com
names:
categories:
- gcp
kind: PubSubSchema
plural: pubsubschemas
shortNames:
- gcppubsubschema
- gcppubsubschemas
singular: pubsubschema
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: v1beta1
schema:
openAPIV3Schema:
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/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/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
definition:
description: |-
Immutable. The definition of the schema.
This should contain a string representing the full definition of the schema
that is a valid schema definition of the type specified in type.
type: string
projectRef:
description: The project that this resource belongs to.
oneOf:
- not:
required:
- external
required:
- name
- not:
anyOf:
- required:
- name
- required:
- namespace
required:
- external
properties:
external:
description: 'Allowed value: The `name` field of a `Project` resource.'
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
type: object
resourceID:
description: Immutable. Optional. The name of the resource. Used for
creation and acquisition. When unset, the value of `metadata.name`
is used as the default.
type: string
type:
description: 'Immutable. The type of the schema definition Default
value: "TYPE_UNSPECIFIED" Possible values: ["TYPE_UNSPECIFIED",
"PROTOCOL_BUFFER", "AVRO"].'
type: string
required:
- projectRef
type: object
status:
properties:
conditions:
description: Conditions represent the latest available observation
of the resource'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
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.
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 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.

apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubSchema
metadata:
name: pubsubsubschema-sample
spec:
type: PROTOCOL_BUFFER
definition: "syntax = \"proto3\";\nmessage Results {\nstring message_request = 1;\nstring message_response = 2;\nstring timestamp_request = 3;\nstring timestamp_response = 4;\n}"
# Replace ${PROJECT_ID?} below with your project ID
projectRef:
external: ${PROJECT_ID?}
21 changes: 21 additions & 0 deletions config/servicemappings/pubsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ spec:
version: v1beta1
serviceHostName: "pubsub.googleapis.com"
resources:
- name: google_pubsub_schema
kind: PubSubSchema
resourceID:
targetField: name
idTemplate: "projects/{{project}}/schemas/{{name}}"
idTemplateCanBeUsedToMatchResourceName: true
resourceAvailableInAssetInventory: false
metadataMapping:
name: name
hierarchicalReferences:
- type: project
key: projectRef
resourceReferences:
- tfField: project
key: projectRef
description: |-
The project that this resource belongs to.
gvk:
kind: Project
version: v1beta1
group: resourcemanager.cnrm.cloud.google.com
- name: google_pubsub_subscription
kind: PubSubSubscription
iamConfig:
Expand Down
89 changes: 89 additions & 0 deletions pkg/clients/generated/apis/pubsub/v1beta1/pubsubschema_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// 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.

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Config Connector and manual
// changes will be clobbered when the file is regenerated.
//
// ----------------------------------------------------------------------------

// *** DISCLAIMER ***
// Config Connector's go-client for CRDs is currently in ALPHA, which means
// that future versions of the go-client may include breaking changes.
// Please try it out and give us feedback!

package v1beta1

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

type PubSubSchemaSpec struct {
/* Immutable. The definition of the schema.
This should contain a string representing the full definition of the schema
that is a valid schema definition of the type specified in type. */
// +optional
Definition *string `json:"definition,omitempty"`

/* The project that this resource belongs to. */
ProjectRef v1alpha1.ResourceRef `json:"projectRef"`

/* 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"`

/* Immutable. The type of the schema definition Default value: "TYPE_UNSPECIFIED" Possible values: ["TYPE_UNSPECIFIED", "PROTOCOL_BUFFER", "AVRO"]. */
// +optional
Type *string `json:"type,omitempty"`
}

type PubSubSchemaStatus struct {
/* Conditions represent the latest available observations of the
PubSubSchema'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 int `json:"observedGeneration,omitempty"`
}

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

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

Spec PubSubSchemaSpec `json:"spec,omitempty"`
Status PubSubSchemaStatus `json:"status,omitempty"`
}

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

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

func init() {
SchemeBuilder.Register(&PubSubSchema{}, &PubSubSchemaList{})
}
6 changes: 6 additions & 0 deletions pkg/clients/generated/apis/pubsub/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ var (
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme

PubSubSchemaGVK = schema.GroupVersionKind{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Kind: reflect.TypeOf(PubSubSchema{}).Name(),
}

PubSubSubscriptionGVK = schema.GroupVersionKind{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Expand Down
Loading

0 comments on commit 7f2c8f4

Please sign in to comment.