From 8512e62144cd972dc5e7256f71deaab582fdbcdc Mon Sep 17 00:00:00 2001 From: justinsb Date: Tue, 4 Jun 2024 13:17:02 -0400 Subject: [PATCH 1/3] feat: create go types for SecureSourceManagerInstance Generated from the proto by dev/tools/proto-to-mapper and then lightly edited / moved around. --- apis/securesourcemanager/v1alpha1/doc.go | 19 ++ .../securesourcemanager/v1alpha1/generated.go | 30 +++ apis/securesourcemanager/v1alpha1/instance.go | 126 ++++++++++ apis/securesourcemanager/v1alpha1/register.go | 22 ++ .../v1alpha1/zz_generated.deepcopy.go | 217 ++++++++++++++++++ ...resourcemanager.cnrm.cloud.google.com.yaml | 187 +++++++++++++++ 6 files changed, 601 insertions(+) create mode 100644 apis/securesourcemanager/v1alpha1/doc.go create mode 100644 apis/securesourcemanager/v1alpha1/generated.go create mode 100644 apis/securesourcemanager/v1alpha1/instance.go create mode 100644 apis/securesourcemanager/v1alpha1/register.go create mode 100644 apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go create mode 100644 config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerinstances.securesourcemanager.cnrm.cloud.google.com.yaml diff --git a/apis/securesourcemanager/v1alpha1/doc.go b/apis/securesourcemanager/v1alpha1/doc.go new file mode 100644 index 0000000000..74fcaf39bc --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/doc.go @@ -0,0 +1,19 @@ +// 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. + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +groupName=securesourcemanager.cnrm.cloud.google.com + +package v1alpha1 diff --git a/apis/securesourcemanager/v1alpha1/generated.go b/apis/securesourcemanager/v1alpha1/generated.go new file mode 100644 index 0000000000..19f483744a --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/generated.go @@ -0,0 +1,30 @@ +// 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.securesourcemanager.v1.Instance.HostConfig +type Instance_HostConfig struct { + // Output only. HTML hostname. + Html *string `json:"html,omitempty"` + + // Output only. API hostname. This is the hostname to use for **Host: Data + // Plane** endpoints. + Api *string `json:"api,omitempty"` + + // Output only. Git HTTP hostname. + GitHttp *string `json:"gitHttp,omitempty"` + + // Output only. Git SSH hostname. + GitSsh *string `json:"gitSsh,omitempty"` +} diff --git a/apis/securesourcemanager/v1alpha1/instance.go b/apis/securesourcemanager/v1alpha1/instance.go new file mode 100644 index 0000000000..daed306538 --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/instance.go @@ -0,0 +1,126 @@ +// 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 ( + "reflect" + + 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" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} + + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + SecureSourceManagerInstanceGVK = schema.GroupVersionKind{ + Group: SchemeGroupVersion.Group, + Version: SchemeGroupVersion.Version, + Kind: reflect.TypeOf(SecureSourceManagerInstance{}).Name(), + } +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerinstance;gcpsecuresourcemanagerinstances +// +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" +// +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'" + +// SecureSourceManagerInstance is the Schema for the monitoring API +// +k8s:openapi-gen=true +type SecureSourceManagerInstance struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +required + Spec SecureSourceManagerInstanceSpec `json:"spec,omitempty"` + + Status SecureSourceManagerInstanceStatus `json:"status,omitempty"` +} + +// +kcc:proto=google.cloud.securesourcemanager.v1.Instance +type SecureSourceManagerInstanceSpec struct { + /* Immutable. The Project that this resource belongs to. */ + ProjectRef refs.ProjectRef `json:"projectRef"` + + /* Immutable. Location of the instance. */ + Location string `json:"location"` + + /* 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. Labels as key value pairs. + Labels map[string]string `json:"labels,omitempty"` + + // Optional. Immutable. Customer-managed encryption key name, in the format + // projects/*/locations/*/keyRings/*/cryptoKeys/*. + KmsKey *string `json:"kmsKey,omitempty"` +} + +// +kcc:proto=google.cloud.securesourcemanager.v1.Instance +type SecureSourceManagerInstanceObservedState struct { + // // Output only. Create timestamp. + // CreateTime *string `json:"createTime,omitempty"` + + // // Output only. Update timestamp. + // UpdateTime *string `json:"updateTime,omitempty"` + + // Output only. Current state of the instance. + State *string `json:"state,omitempty"` + + // Output only. An optional field providing information about the current + // instance state. + StateNote *string `json:"stateNote,omitempty"` + + // Output only. A list of hostnames for this instance. + HostConfig *Instance_HostConfig `json:"hostConfig,omitempty"` +} + +type SecureSourceManagerInstanceStatus struct { + /* Conditions represent the latest available observations of the + SecureSourceManagerInstance's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + + /* ObservedState is the latest GCP state. */ + ObservedState *SecureSourceManagerInstanceObservedState `json:"observedState,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"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SecureSourceManagerInstanceList contains a list of SecureSourceManagerInstance +type SecureSourceManagerInstanceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SecureSourceManagerInstance `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SecureSourceManagerInstance{}, &SecureSourceManagerInstanceList{}) +} diff --git a/apis/securesourcemanager/v1alpha1/register.go b/apis/securesourcemanager/v1alpha1/register.go new file mode 100644 index 0000000000..e4ac50a106 --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/register.go @@ -0,0 +1,22 @@ +// 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 "k8s.io/apimachinery/pkg/runtime/schema" + +var ( + // SchemeGroupVersion is the group version used to register these objects. + SchemeGroupVersion = schema.GroupVersion{Group: "securesourcemanager.cnrm.cloud.google.com", Version: "v1alpha1"} +) diff --git a/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..a0fe6c538f --- /dev/null +++ b/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,217 @@ +//go:build !ignore_autogenerated +// +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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + 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 *Instance_HostConfig) DeepCopyInto(out *Instance_HostConfig) { + *out = *in + if in.Html != nil { + in, out := &in.Html, &out.Html + *out = new(string) + **out = **in + } + if in.Api != nil { + in, out := &in.Api, &out.Api + *out = new(string) + **out = **in + } + if in.GitHttp != nil { + in, out := &in.GitHttp, &out.GitHttp + *out = new(string) + **out = **in + } + if in.GitSsh != nil { + in, out := &in.GitSsh, &out.GitSsh + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instance_HostConfig. +func (in *Instance_HostConfig) DeepCopy() *Instance_HostConfig { + if in == nil { + return nil + } + out := new(Instance_HostConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstance) DeepCopyInto(out *SecureSourceManagerInstance) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstance. +func (in *SecureSourceManagerInstance) DeepCopy() *SecureSourceManagerInstance { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerInstance) 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 *SecureSourceManagerInstanceList) DeepCopyInto(out *SecureSourceManagerInstanceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SecureSourceManagerInstance, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceList. +func (in *SecureSourceManagerInstanceList) DeepCopy() *SecureSourceManagerInstanceList { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerInstanceList) 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 *SecureSourceManagerInstanceObservedState) DeepCopyInto(out *SecureSourceManagerInstanceObservedState) { + *out = *in + if in.State != nil { + in, out := &in.State, &out.State + *out = new(string) + **out = **in + } + if in.StateNote != nil { + in, out := &in.StateNote, &out.StateNote + *out = new(string) + **out = **in + } + if in.HostConfig != nil { + in, out := &in.HostConfig, &out.HostConfig + *out = new(Instance_HostConfig) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceObservedState. +func (in *SecureSourceManagerInstanceObservedState) DeepCopy() *SecureSourceManagerInstanceObservedState { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstanceSpec) DeepCopyInto(out *SecureSourceManagerInstanceSpec) { + *out = *in + out.ProjectRef = in.ProjectRef + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.KmsKey != nil { + in, out := &in.KmsKey, &out.KmsKey + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceSpec. +func (in *SecureSourceManagerInstanceSpec) DeepCopy() *SecureSourceManagerInstanceSpec { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstanceStatus) DeepCopyInto(out *SecureSourceManagerInstanceStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]k8sv1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(SecureSourceManagerInstanceObservedState) + (*in).DeepCopyInto(*out) + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceStatus. +func (in *SecureSourceManagerInstanceStatus) DeepCopy() *SecureSourceManagerInstanceStatus { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerinstances.securesourcemanager.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerinstances.securesourcemanager.cnrm.cloud.google.com.yaml new file mode 100644 index 0000000000..618ab4594b --- /dev/null +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_securesourcemanagerinstances.securesourcemanager.cnrm.cloud.google.com.yaml @@ -0,0 +1,187 @@ +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: alpha + cnrm.cloud.google.com/system: "true" + name: securesourcemanagerinstances.securesourcemanager.cnrm.cloud.google.com +spec: + group: securesourcemanager.cnrm.cloud.google.com + names: + categories: + - gcp + kind: SecureSourceManagerInstance + listKind: SecureSourceManagerInstanceList + plural: securesourcemanagerinstances + shortNames: + - gcpsecuresourcemanagerinstance + - gcpsecuresourcemanagerinstances + singular: securesourcemanagerinstance + 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: SecureSourceManagerInstance is the Schema for the monitoring + 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: + properties: + kmsKey: + description: Optional. Immutable. Customer-managed encryption key + name, in the format projects/*/locations/*/keyRings/*/cryptoKeys/*. + type: string + labels: + additionalProperties: + type: string + description: Optional. Labels as key value pairs. + type: object + location: + description: Immutable. Location of the instance. + type: string + projectRef: + description: Immutable. The Project that this resource belongs to. + 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 KCC. + 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. 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 + required: + - location + - projectRef + type: object + status: + properties: + conditions: + description: Conditions represent the latest available observations + of the SecureSourceManagerInstance'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. + format: int64 + type: integer + observedState: + description: ObservedState is the latest GCP state. + properties: + hostConfig: + description: Output only. A list of hostnames for this instance. + properties: + api: + description: 'Output only. API hostname. This is the hostname + to use for **Host: Data Plane** endpoints.' + type: string + gitHttp: + description: Output only. Git HTTP hostname. + type: string + gitSsh: + description: Output only. Git SSH hostname. + type: string + html: + description: Output only. HTML hostname. + type: string + type: object + state: + description: Output only. Current state of the instance. + type: string + stateNote: + description: Output only. An optional field providing information + about the current instance state. + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} From cf373e0e0d4940ebf7e39ce535a9ad1a341aeb5e Mon Sep 17 00:00:00 2001 From: justinsb Date: Tue, 4 Jun 2024 13:44:34 -0400 Subject: [PATCH 2/3] securesourcemanager: add generated mappings and round-trip tests --- go.mod | 1 + go.sum | 2 + .../securesourcemanager/mapper.generated.go | 105 +++++ .../direct/securesourcemanager/maputils.go | 188 ++++++++ .../securesourcemanager/roundtrip_test.go | 412 ++++++++++++++++++ .../direct/securesourcemanager/utils.go | 27 ++ 6 files changed, 735 insertions(+) create mode 100644 pkg/controller/direct/securesourcemanager/mapper.generated.go create mode 100644 pkg/controller/direct/securesourcemanager/maputils.go create mode 100644 pkg/controller/direct/securesourcemanager/roundtrip_test.go create mode 100644 pkg/controller/direct/securesourcemanager/utils.go diff --git a/go.mod b/go.mod index 9c5ed0ca34..d795b4e2e3 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( cloud.google.com/go/monitoring v1.19.0 cloud.google.com/go/profiler v0.1.0 cloud.google.com/go/resourcemanager v1.9.7 + cloud.google.com/go/securesourcemanager v0.1.5 contrib.go.opencensus.io/exporter/prometheus v0.1.0 github.com/GoogleCloudPlatform/declarative-resource-client-library v1.62.0 github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp v0.0.0-00010101000000-000000000000 diff --git a/go.sum b/go.sum index de17257369..ea40b873b2 100644 --- a/go.sum +++ b/go.sum @@ -62,6 +62,8 @@ cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIA cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/resourcemanager v1.9.7 h1:SdvD0PaPX60+yeKoSe16mawFpM0EPuiPPihTIVlhRsY= cloud.google.com/go/resourcemanager v1.9.7/go.mod h1:cQH6lJwESufxEu6KepsoNAsjrUtYYNXRwxm4QFE5g8A= +cloud.google.com/go/securesourcemanager v0.1.5 h1:+6x067eHPHyDU8ed+ybNEWudtngaz/bAoehhyy5bO5M= +cloud.google.com/go/securesourcemanager v0.1.5/go.mod h1:RTBWXAILmlm91TsDBmKUzUevfjB1HSXo85nsF8JEWjc= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= diff --git a/pkg/controller/direct/securesourcemanager/mapper.generated.go b/pkg/controller/direct/securesourcemanager/mapper.generated.go new file mode 100644 index 0000000000..c6b30a57f5 --- /dev/null +++ b/pkg/controller/direct/securesourcemanager/mapper.generated.go @@ -0,0 +1,105 @@ +// 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 securesourcemanager + +import ( + pb "cloud.google.com/go/securesourcemanager/apiv1/securesourcemanagerpb" + + krm "github.com/GoogleCloudPlatform/k8s-config-connector/apis/securesourcemanager/v1alpha1" +) + +func Instance_HostConfig_FromProto(mapCtx *MapContext, in *pb.Instance_HostConfig) *krm.Instance_HostConfig { + if in == nil { + return nil + } + out := &krm.Instance_HostConfig{} + out.Html = LazyPtr(in.GetHtml()) + out.Api = LazyPtr(in.GetApi()) + out.GitHttp = LazyPtr(in.GetGitHttp()) + out.GitSsh = LazyPtr(in.GetGitSsh()) + return out +} +func Instance_HostConfig_ToProto(mapCtx *MapContext, in *krm.Instance_HostConfig) *pb.Instance_HostConfig { + if in == nil { + return nil + } + out := &pb.Instance_HostConfig{} + out.Html = ValueOf(in.Html) + out.Api = ValueOf(in.Api) + out.GitHttp = ValueOf(in.GitHttp) + out.GitSsh = ValueOf(in.GitSsh) + return out +} + +func SecureSourceManagerInstanceObservedState_FromProto(mapCtx *MapContext, in *pb.Instance) *krm.SecureSourceManagerInstanceObservedState { + if in == nil { + return nil + } + out := &krm.SecureSourceManagerInstanceObservedState{} + // MISSING: Name + // MISSING: CreateTime + // MISSING: UpdateTime + // MISSING: Labels + out.State = Enum_FromProto(mapCtx, in.State) + out.StateNote = Enum_FromProto(mapCtx, in.StateNote) + // MISSING: KmsKey + out.HostConfig = Instance_HostConfig_FromProto(mapCtx, in.GetHostConfig()) + return out +} +func SecureSourceManagerInstanceObservedState_ToProto(mapCtx *MapContext, in *krm.SecureSourceManagerInstanceObservedState) *pb.Instance { + if in == nil { + return nil + } + out := &pb.Instance{} + // MISSING: Name + // MISSING: CreateTime + // MISSING: UpdateTime + // MISSING: Labels + out.State = Enum_ToProto[pb.Instance_State](mapCtx, in.State) + out.StateNote = Enum_ToProto[pb.Instance_StateNote](mapCtx, in.StateNote) + // MISSING: KmsKey + out.HostConfig = Instance_HostConfig_ToProto(mapCtx, in.HostConfig) + return out +} +func SecureSourceManagerInstanceSpec_FromProto(mapCtx *MapContext, in *pb.Instance) *krm.SecureSourceManagerInstanceSpec { + if in == nil { + return nil + } + out := &krm.SecureSourceManagerInstanceSpec{} + // MISSING: Name + // MISSING: CreateTime + // MISSING: UpdateTime + out.Labels = in.Labels + // MISSING: State + // MISSING: StateNote + out.KmsKey = LazyPtr(in.GetKmsKey()) + // MISSING: HostConfig + return out +} +func SecureSourceManagerInstanceSpec_ToProto(mapCtx *MapContext, in *krm.SecureSourceManagerInstanceSpec) *pb.Instance { + if in == nil { + return nil + } + out := &pb.Instance{} + // MISSING: Name + // MISSING: CreateTime + // MISSING: UpdateTime + out.Labels = in.Labels + // MISSING: State + // MISSING: StateNote + out.KmsKey = ValueOf(in.KmsKey) + // MISSING: HostConfig + return out +} diff --git a/pkg/controller/direct/securesourcemanager/maputils.go b/pkg/controller/direct/securesourcemanager/maputils.go new file mode 100644 index 0000000000..b42fff96b8 --- /dev/null +++ b/pkg/controller/direct/securesourcemanager/maputils.go @@ -0,0 +1,188 @@ +// 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 securesourcemanager + +import ( + "errors" + "fmt" + "strconv" + "strings" + "time" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/durationpb" +) + +type MapContext struct { + errs []error +} + +func (c *MapContext) Errorf(msg string, args ...interface{}) { + c.errs = append(c.errs, fmt.Errorf(msg, args...)) +} + +func (c *MapContext) Err() error { + return errors.Join(c.errs...) +} + +func Slice_ToProto[T, U any](mapCtx *MapContext, in []T, mapper func(mapCtx *MapContext, in *T) *U) []*U { + if in == nil { + return nil + } + + outSlice := make([]*U, 0, len(in)) + for _, inItem := range in { + outItem := mapper(mapCtx, &inItem) + outSlice = append(outSlice, outItem) + } + return outSlice +} + +func Slice_FromProto[T, U any](mapCtx *MapContext, in []*T, mapper func(mapCtx *MapContext, in *T) *U) []U { + if in == nil { + return nil + } + + outSlice := make([]U, 0, len(in)) + for _, inItem := range in { + outItem := mapper(mapCtx, inItem) + outSlice = append(outSlice, *outItem) + } + return outSlice +} + +type ProtoEnum interface { + ~int32 + Descriptor() protoreflect.EnumDescriptor +} + +func Enum_ToProto[U ProtoEnum](mapCtx *MapContext, in *string) U { + var defaultU U + descriptor := defaultU.Descriptor() + + inValue := ValueOf(in) + if inValue == "" { + unspecifiedValue := U(0) + return unspecifiedValue + } + + n := descriptor.Values().Len() + for i := 0; i < n; i++ { + value := descriptor.Values().Get(i) + if string(value.Name()) == inValue { + v := U(value.Number()) + return v + } + } + + var validValues []string + for i := 0; i < n; i++ { + value := descriptor.Values().Get(i) + validValues = append(validValues, string(value.Name())) + } + + mapCtx.Errorf("unknown enum value %q for %v (valid values are %v)", inValue, descriptor.FullName(), strings.Join(validValues, ", ")) + return 0 +} + +func Enum_FromProto[U ProtoEnum](mapCtx *MapContext, v U) *string { + descriptor := v.Descriptor() + + if v == 0 { + return nil + } + + val := descriptor.Values().ByNumber(protoreflect.EnumNumber(v)) + if val == nil { + mapCtx.Errorf("unknown enum value %d", v) + return nil + } + s := string(val.Name()) + return &s +} + +func Duration_ToProto(mapCtx *MapContext, in *string) *durationpb.Duration { + if in == nil { + return nil + } + + s := *in + if s == "" { + return nil + } + + if strings.HasPrefix(s, "seconds:") { + v := strings.TrimPrefix(s, "seconds:") + d, err := time.ParseDuration(v + "s") + if err != nil { + mapCtx.Errorf("parsing duration %q: %w", v, err) + return nil + } + out := durationpb.New(d) + return out + } + + // TODO: Is this 1:1 with durationpb? + d, err := time.ParseDuration(s) + if err != nil { + mapCtx.Errorf("parsing duration %q: %w", s, err) + return nil + } + out := durationpb.New(d) + return out +} + +func Duration_FromProto(mapCtx *MapContext, in *durationpb.Duration) *string { + if in == nil { + return nil + } + + s := in.String() + return &s +} + +func LazyPtr[V comparable](v V) *V { + var defaultV V + if v == defaultV { + return nil + } + return &v +} + +func SecondsString_FromProto(mapCtx *MapContext, in *durationpb.Duration) *string { + if in == nil { + return nil + } + seconds := in.GetSeconds() + out := strconv.FormatInt(seconds, 10) + return &out +} + +func SecondsString_ToProto(mapCtx *MapContext, in *string, fieldName string) *durationpb.Duration { + if in == nil { + return nil + } + v := *in + if strings.HasSuffix(v, "s") { + v = strings.TrimSuffix(v, "s") + } + seconds, err := strconv.ParseInt(v, 10, 64) + if err != nil { + mapCtx.Errorf("%s value %q is not valid", fieldName, *in) + return nil + } + out := &durationpb.Duration{Seconds: seconds} + return out +} diff --git a/pkg/controller/direct/securesourcemanager/roundtrip_test.go b/pkg/controller/direct/securesourcemanager/roundtrip_test.go new file mode 100644 index 0000000000..9a5b18421a --- /dev/null +++ b/pkg/controller/direct/securesourcemanager/roundtrip_test.go @@ -0,0 +1,412 @@ +// 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 securesourcemanager + +import ( + "fmt" + "math/rand" + "testing" + + pb "cloud.google.com/go/securesourcemanager/apiv1/securesourcemanagerpb" + + "github.com/google/go-cmp/cmp" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/testing/protocmp" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/klog/v2" +) + +func FuzzSecureSourceManagerInstanceSpec(f *testing.F) { + f.Fuzz(func(t *testing.T, seed int64) { + randStream := rand.New(rand.NewSource(seed)) + + p1 := &pb.Instance{} + fillWithRandom(t, randStream, p1) + + // We don't expect output fields to round-trip + ignoreFields := sets.New( + // Handled specially + ".name", + + // ObservedState (output) fields + ".host_config", + ".state", + ".state_note", + ".create_time", + ".update_time", + ) + + // A few fields are not implemented yet in KRM, don't test them + unimplementedFields := sets.New[string]() + + // Remove any output only or known-unimplemented fields + clearFields := &ClearFields{ + Paths: unimplementedFields.Union(ignoreFields), + } + visit("", p1.ProtoReflect(), nil, clearFields) + + ctx := &MapContext{} + k := SecureSourceManagerInstanceSpec_FromProto(ctx, p1) + if ctx.Err() != nil { + t.Fatalf("error mapping from proto to krm: %v", ctx.Err()) + } + + p2 := SecureSourceManagerInstanceSpec_ToProto(ctx, k) + if ctx.Err() != nil { + t.Fatalf("error mapping from krm to proto: %v", ctx.Err()) + } + + if diff := cmp.Diff(p1, p2, protocmp.Transform()); diff != "" { + t.Logf("p1 = %v", prototext.Format(p1)) + t.Logf("p2 = %v", prototext.Format(p2)) + t.Errorf("roundtrip failed; diff:\n%s", diff) + } + }) +} + +func FuzzSecureSourceManagerInstanceObservedState(f *testing.F) { + f.Fuzz(func(t *testing.T, seed int64) { + randStream := rand.New(rand.NewSource(seed)) + + p1 := &pb.Instance{} + fillWithRandom(t, randStream, p1) + + // We don't expect spec fields to round-trip + ignoreFields := sets.New( + ".name", + ".kms_key", + ".labels", + ) + + // A few fields are not implemented yet in KRM, don't test them + unimplementedFields := sets.New( + ".create_time", + ".update_time", + ) + + // Remove any output only or known-unimplemented fields + clearFields := &ClearFields{ + Paths: unimplementedFields.Union(ignoreFields), + } + visit("", p1.ProtoReflect(), nil, clearFields) + + ctx := &MapContext{} + k := SecureSourceManagerInstanceObservedState_FromProto(ctx, p1) + if ctx.Err() != nil { + t.Fatalf("error mapping from proto to krm: %v", ctx.Err()) + } + + p2 := SecureSourceManagerInstanceObservedState_ToProto(ctx, k) + if ctx.Err() != nil { + t.Fatalf("error mapping from krm to proto: %v", ctx.Err()) + } + + if diff := cmp.Diff(p1, p2, protocmp.Transform()); diff != "" { + t.Logf("p1 = %v", prototext.Format(p1)) + t.Logf("p2 = %v", prototext.Format(p2)) + t.Errorf("roundtrip failed; diff:\n%s", diff) + } + }) +} + +func fillWithRandom(t *testing.T, randStream *rand.Rand, msg proto.Message) { + fillWithRandom0(t, randStream, msg.ProtoReflect()) +} + +func fillWithRandom0(t *testing.T, randStream *rand.Rand, msg protoreflect.Message) { + descriptor := msg.Descriptor() + if string(descriptor.FullName()) == "google.protobuf.Duration" { + count := randStream.Intn(10) + // Bias to zero + if count > 4 { + return + } + seconds := randStream.Intn(365 * 24 * 60 * 60) + nanos := randStream.Intn(1000000000) + msg.Set(descriptor.Fields().ByName("seconds"), protoreflect.ValueOfInt32(int32(seconds))) + msg.Set(descriptor.Fields().ByName("nanos"), protoreflect.ValueOfInt32(int32(nanos))) + return + } + + fields := descriptor.Fields() + n := fields.Len() + for i := 0; i < n; i++ { + field := fields.Get(i) + + if field.IsList() { + count := randStream.Intn(10) + // Bias heavily to zero + if count > 4 { + count = 0 + } + listVal := msg.Mutable(field).List() + switch field.Kind() { + case protoreflect.MessageKind: + for j := 0; j < count; j++ { + el := listVal.AppendMutable() + fillWithRandom0(t, randStream, el.Message()) + } + case protoreflect.StringKind: + for j := 0; j < count; j++ { + s := randomString(randStream) + listVal.Append(protoreflect.ValueOf(s)) + } + + default: + t.Fatalf("unhandled field kind %v: %v", field.Kind(), field) + } + continue + } + + if field.IsMap() { + count := randStream.Intn(10) + // Bias heavily to zero + if count > 4 { + count = 0 + } + mapType := fmt.Sprintf("%s->%s", field.MapKey().Kind(), field.MapValue().Kind()) + switch mapType { + case "string->string": + mapVal := msg.Mutable(field).Map() + for j := 0; j < count; j++ { + k := randomString(randStream) + v := randomString(randStream) + mapVal.Set(protoreflect.ValueOf(k).MapKey(), protoreflect.ValueOf(v)) + } + + default: + t.Fatalf("unhandled map kind %q: %v", mapType, field) + } + continue + } + + if field.Cardinality() == protoreflect.Optional { + if randStream.Intn(3) < 2 { + continue + } + } + + switch field.Kind() { + case protoreflect.MessageKind: + fieldVal := msg.Mutable(field) + fillWithRandom0(t, randStream, fieldVal.Message()) + + case protoreflect.BoolKind: + msg.Set(field, protoreflect.ValueOfBool(randStream.Intn(2) == 1)) + + case protoreflect.DoubleKind: + msg.Set(field, protoreflect.ValueOfFloat64(randStream.NormFloat64())) + case protoreflect.Int32Kind: + msg.Set(field, protoreflect.ValueOfInt32(randStream.Int31())) + case protoreflect.Int64Kind: + msg.Set(field, protoreflect.ValueOfInt64(randStream.Int63())) + case protoreflect.StringKind: + s := randomString(randStream) + msg.Set(field, protoreflect.ValueOfString(s)) + case protoreflect.EnumKind: + fieldDescriptor := field.Enum() + n := fieldDescriptor.Values().Len() + val := fieldDescriptor.Values().Get(randStream.Intn(n)) + msg.Set(field, protoreflect.ValueOf(val.Number())) + default: + t.Fatalf("unhandled field kind %v: %v", field.Kind(), field) + } + } +} + +func randomString(randStream *rand.Rand) string { + // TODO: This is not a good random string! + return fmt.Sprintf("%x", randStream.Int63()) +} + +type ProtoVisitor interface { + VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value)) + VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value)) + VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value)) + VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value)) +} + +type ProtoVisitorBase struct { +} + +func (v *ProtoVisitorBase) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value)) { + +} + +func (v *ProtoVisitorBase) VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value)) { +} + +func (v *ProtoVisitorBase) VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value)) { +} + +func (v *ProtoVisitorBase) VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value)) { +} + +var _ ProtoVisitor = &ProtoVisitorBase{} + +type ClearFields struct { + ProtoVisitorBase + + Paths sets.Set[string] +} + +func (v *ClearFields) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value)) { + if v.Paths.Has(path) { + setter(protoreflect.Value{}) + } +} + +func (v *ClearFields) VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value)) { + if v.Paths.Has(path) { + setter(protoreflect.Value{}) + } +} + +func (v *ClearFields) VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value)) { + if v.Paths.Has(path) { + setter(protoreflect.Value{}) + } +} + +func (v *ClearFields) VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value)) { + if v.Paths.Has(path) { + setter(protoreflect.Value{}) + } +} + +var _ ProtoVisitor = &ClearFields{} + +type ReplaceFields struct { + ProtoVisitorBase + + Func func(path string, val protoreflect.Value) (protoreflect.Value, bool) +} + +func (v *ReplaceFields) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value)) { + if newVal, ok := v.Func(path, val); ok { + setter(newVal) + } +} + +var _ ProtoVisitor = &ClearFields{} + +func visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect.Value), visitor ProtoVisitor) { + visitor.VisitMessage(msgPath, msg, setter) + msg.Range(func(field protoreflect.FieldDescriptor, fieldVal protoreflect.Value) bool { + path := msgPath + "." + string(field.Name()) + klog.Infof("visit %q", path) + + if field.IsList() { + listVal := fieldVal.List() + setter := func(v protoreflect.Value) { + if v.IsValid() { + msg.Set(field, v) + } else { + msg.Clear(field) + } + } + visitor.VisitList(path, listVal, setter) + count := listVal.Len() + switch field.Kind() { + case protoreflect.MessageKind: + for j := 0; j < count; j++ { + el := listVal.Get(j) + setter := func(v protoreflect.Value) { + listVal.Set(j, v) + } + visit(path+"[]", el.Message(), setter, visitor) + } + case protoreflect.StringKind: + 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) + } + return true + } + + if field.IsMap() { + mapType := fmt.Sprintf("%s->%s", field.MapKey().Kind(), field.MapValue().Kind()) + switch mapType { + case "string->string": + 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) + } + visitor.VisitPrimitive(mapPath, val, setter) + return true + }) + + default: + klog.Fatalf("unhandled map kind %q: %v", mapType, field) + } + return true + } + + switch field.Kind() { + case protoreflect.MessageKind: + setter := func(v protoreflect.Value) { + if v.IsValid() { + msg.Set(field, v) + } else { + msg.Clear(field) + } + } + visit(path, fieldVal.Message(), setter, visitor) + + case protoreflect.BoolKind, + protoreflect.DoubleKind, + protoreflect.Int32Kind, + protoreflect.Int64Kind, + protoreflect.StringKind, + protoreflect.EnumKind: + setter := func(v protoreflect.Value) { + if v.IsValid() { + msg.Set(field, v) + } else { + msg.Clear(field) + } + } + visitor.VisitPrimitive(path, fieldVal, setter) + + default: + klog.Fatalf("unhandled field kind %v: %v", field.Kind(), field) + } + + return true + }) + +} diff --git a/pkg/controller/direct/securesourcemanager/utils.go b/pkg/controller/direct/securesourcemanager/utils.go new file mode 100644 index 0000000000..7988fd8ddd --- /dev/null +++ b/pkg/controller/direct/securesourcemanager/utils.go @@ -0,0 +1,27 @@ +// 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 securesourcemanager + +func ValueOf[T any](p *T) T { + var v T + if p != nil { + v = *p + } + return v +} + +func PtrTo[T any](t T) *T { + return &t +} From 3378e892b19cb5a299c747dce8da6a0bed1b3604 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 5 Jun 2024 11:12:56 -0400 Subject: [PATCH 3/3] autogen: generated clients for securesourcemanager --- .../apis/securesourcemanager/group.go | 32 +++ .../apis/securesourcemanager/v1alpha1/doc.go | 41 ++++ .../securesourcemanager/v1alpha1/register.go | 63 +++++ .../securesourcemanagerinstance_types.go | 134 +++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 223 ++++++++++++++++++ .../client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../typed/securesourcemanager/v1alpha1/doc.go | 23 ++ .../securesourcemanager/v1alpha1/fake/doc.go | 23 ++ .../fake/fake_securesourcemanager_client.go | 43 ++++ .../fake/fake_securesourcemanagerinstance.go | 144 +++++++++++ .../v1alpha1/generated_expansion.go | 24 ++ .../v1alpha1/securesourcemanager_client.go | 110 +++++++++ .../v1alpha1/securesourcemanagerinstance.go | 198 ++++++++++++++++ 16 files changed, 1082 insertions(+) create mode 100644 pkg/clients/generated/apis/securesourcemanager/group.go create mode 100644 pkg/clients/generated/apis/securesourcemanager/v1alpha1/doc.go create mode 100644 pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go create mode 100644 pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerinstance_types.go create mode 100644 pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/doc.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/doc.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerinstance.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go create mode 100644 pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerinstance.go diff --git a/pkg/clients/generated/apis/securesourcemanager/group.go b/pkg/clients/generated/apis/securesourcemanager/group.go new file mode 100644 index 0000000000..0fb8cbf8b4 --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/group.go @@ -0,0 +1,32 @@ +// 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 securesourcemanager contains securesourcemanager API versions. +package securesourcemanager diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/doc.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/doc.go new file mode 100644 index 0000000000..d1bfad7c5e --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/doc.go @@ -0,0 +1,41 @@ +// 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 v1alpha1 contains API Schema definitions for the securesourcemanager v1alpha1 API group. +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/pkg/apis/securesourcemanager +// +k8s:defaulter-gen=TypeMeta +// +groupName=securesourcemanager.cnrm.cloud.google.com + +// Generate deepcopy object for securesourcemanager/v1alpha1 API group +// +//go:generate go run ../../../../../../scripts/deepcopy-gen/main.go -O zz_generated.deepcopy -i . -h ../../../../../../hack/boilerplate_client_alpha.go.txt +package v1alpha1 diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go new file mode 100644 index 0000000000..4a6331cf28 --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/register.go @@ -0,0 +1,63 @@ +// 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 v1alpha1 contains API Schema definitions for the securesourcemanager v1alpha1 API group. +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/pkg/apis/securesourcemanager +// +k8s:defaulter-gen=TypeMeta +// +groupName=securesourcemanager.cnrm.cloud.google.com +package v1alpha1 + +import ( + "reflect" + + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // SchemeGroupVersion is the group version used to register these objects. + SchemeGroupVersion = schema.GroupVersion{Group: "securesourcemanager.cnrm.cloud.google.com", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} + + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + SecureSourceManagerInstanceGVK = schema.GroupVersionKind{ + Group: SchemeGroupVersion.Group, + Version: SchemeGroupVersion.Version, + Kind: reflect.TypeOf(SecureSourceManagerInstance{}).Name(), + } + + securesourcemanagerAPIVersion = SchemeGroupVersion.String() +) diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerinstance_types.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerinstance_types.go new file mode 100644 index 0000000000..da649f90ae --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/securesourcemanagerinstance_types.go @@ -0,0 +1,134 @@ +// 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 v1alpha1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type SecureSourceManagerInstanceSpec struct { + /* Optional. Immutable. Customer-managed encryption key name, in the format projects/* /locations/* /keyRings/* /cryptoKeys/*. */ + // +optional + KmsKey *string `json:"kmsKey,omitempty"` + + /* Optional. Labels as key value pairs. */ + // +optional + Labels map[string]string `json:"labels,omitempty"` + + /* Immutable. Location of the instance. */ + Location string `json:"location"` + + /* Immutable. 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"` +} + +type InstanceHostConfigStatus struct { + /* Output only. API hostname. This is the hostname to use for **Host: Data Plane** endpoints. */ + // +optional + Api *string `json:"api,omitempty"` + + /* Output only. Git HTTP hostname. */ + // +optional + GitHttp *string `json:"gitHttp,omitempty"` + + /* Output only. Git SSH hostname. */ + // +optional + GitSsh *string `json:"gitSsh,omitempty"` + + /* Output only. HTML hostname. */ + // +optional + Html *string `json:"html,omitempty"` +} + +type InstanceObservedStateStatus struct { + /* Output only. A list of hostnames for this instance. */ + // +optional + HostConfig *InstanceHostConfigStatus `json:"hostConfig,omitempty"` + + /* Output only. Current state of the instance. */ + // +optional + State *string `json:"state,omitempty"` + + /* Output only. An optional field providing information about the current instance state. */ + // +optional + StateNote *string `json:"stateNote,omitempty"` +} + +type SecureSourceManagerInstanceStatus struct { + /* Conditions represent the latest available observations of the + SecureSourceManagerInstance'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"` + + /* ObservedState is the latest GCP state. */ + // +optional + ObservedState *InstanceObservedStateStatus `json:"observedState,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpsecuresourcemanagerinstance;gcpsecuresourcemanagerinstances +// +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" +// +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'" + +// SecureSourceManagerInstance is the Schema for the securesourcemanager API +// +k8s:openapi-gen=true +type SecureSourceManagerInstance struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SecureSourceManagerInstanceSpec `json:"spec,omitempty"` + Status SecureSourceManagerInstanceStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SecureSourceManagerInstanceList contains a list of SecureSourceManagerInstance +type SecureSourceManagerInstanceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SecureSourceManagerInstance `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SecureSourceManagerInstance{}, &SecureSourceManagerInstanceList{}) +} diff --git a/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..99cbfffc4e --- /dev/null +++ b/pkg/clients/generated/apis/securesourcemanager/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,223 @@ +//go:build !ignore_autogenerated +// +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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package v1alpha1 + +import ( + k8sv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/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 *InstanceHostConfigStatus) DeepCopyInto(out *InstanceHostConfigStatus) { + *out = *in + if in.Api != nil { + in, out := &in.Api, &out.Api + *out = new(string) + **out = **in + } + if in.GitHttp != nil { + in, out := &in.GitHttp, &out.GitHttp + *out = new(string) + **out = **in + } + if in.GitSsh != nil { + in, out := &in.GitSsh, &out.GitSsh + *out = new(string) + **out = **in + } + if in.Html != nil { + in, out := &in.Html, &out.Html + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceHostConfigStatus. +func (in *InstanceHostConfigStatus) DeepCopy() *InstanceHostConfigStatus { + if in == nil { + return nil + } + out := new(InstanceHostConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceObservedStateStatus) DeepCopyInto(out *InstanceObservedStateStatus) { + *out = *in + if in.HostConfig != nil { + in, out := &in.HostConfig, &out.HostConfig + *out = new(InstanceHostConfigStatus) + (*in).DeepCopyInto(*out) + } + if in.State != nil { + in, out := &in.State, &out.State + *out = new(string) + **out = **in + } + if in.StateNote != nil { + in, out := &in.StateNote, &out.StateNote + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceObservedStateStatus. +func (in *InstanceObservedStateStatus) DeepCopy() *InstanceObservedStateStatus { + if in == nil { + return nil + } + out := new(InstanceObservedStateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstance) DeepCopyInto(out *SecureSourceManagerInstance) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstance. +func (in *SecureSourceManagerInstance) DeepCopy() *SecureSourceManagerInstance { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerInstance) 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 *SecureSourceManagerInstanceList) DeepCopyInto(out *SecureSourceManagerInstanceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SecureSourceManagerInstance, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceList. +func (in *SecureSourceManagerInstanceList) DeepCopy() *SecureSourceManagerInstanceList { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SecureSourceManagerInstanceList) 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 *SecureSourceManagerInstanceSpec) DeepCopyInto(out *SecureSourceManagerInstanceSpec) { + *out = *in + if in.KmsKey != nil { + in, out := &in.KmsKey, &out.KmsKey + *out = new(string) + **out = **in + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + out.ProjectRef = in.ProjectRef + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceSpec. +func (in *SecureSourceManagerInstanceSpec) DeepCopy() *SecureSourceManagerInstanceSpec { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecureSourceManagerInstanceStatus) DeepCopyInto(out *SecureSourceManagerInstanceStatus) { + *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.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(InstanceObservedStateStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecureSourceManagerInstanceStatus. +func (in *SecureSourceManagerInstanceStatus) DeepCopy() *SecureSourceManagerInstanceStatus { + if in == nil { + return nil + } + out := new(SecureSourceManagerInstanceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/clients/generated/client/clientset/versioned/clientset.go b/pkg/clients/generated/client/clientset/versioned/clientset.go index f1b08172ef..32a1add47a 100644 --- a/pkg/clients/generated/client/clientset/versioned/clientset.go +++ b/pkg/clients/generated/client/clientset/versioned/clientset.go @@ -121,6 +121,7 @@ import ( resourcemanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/resourcemanager/v1beta1" runv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/run/v1beta1" secretmanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/secretmanager/v1beta1" + securesourcemanagerv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1" securitycenterv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securitycenter/v1alpha1" servicedirectoryv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/servicedirectory/v1beta1" servicenetworkingv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/servicenetworking/v1beta1" @@ -244,6 +245,7 @@ type Interface interface { ResourcemanagerV1beta1() resourcemanagerv1beta1.ResourcemanagerV1beta1Interface RunV1beta1() runv1beta1.RunV1beta1Interface SecretmanagerV1beta1() secretmanagerv1beta1.SecretmanagerV1beta1Interface + SecuresourcemanagerV1alpha1() securesourcemanagerv1alpha1.SecuresourcemanagerV1alpha1Interface SecuritycenterV1alpha1() securitycenterv1alpha1.SecuritycenterV1alpha1Interface ServicedirectoryV1beta1() servicedirectoryv1beta1.ServicedirectoryV1beta1Interface ServicenetworkingV1beta1() servicenetworkingv1beta1.ServicenetworkingV1beta1Interface @@ -365,6 +367,7 @@ type Clientset struct { resourcemanagerV1beta1 *resourcemanagerv1beta1.ResourcemanagerV1beta1Client runV1beta1 *runv1beta1.RunV1beta1Client secretmanagerV1beta1 *secretmanagerv1beta1.SecretmanagerV1beta1Client + securesourcemanagerV1alpha1 *securesourcemanagerv1alpha1.SecuresourcemanagerV1alpha1Client securitycenterV1alpha1 *securitycenterv1alpha1.SecuritycenterV1alpha1Client servicedirectoryV1beta1 *servicedirectoryv1beta1.ServicedirectoryV1beta1Client servicenetworkingV1beta1 *servicenetworkingv1beta1.ServicenetworkingV1beta1Client @@ -867,6 +870,11 @@ func (c *Clientset) SecretmanagerV1beta1() secretmanagerv1beta1.SecretmanagerV1b return c.secretmanagerV1beta1 } +// SecuresourcemanagerV1alpha1 retrieves the SecuresourcemanagerV1alpha1Client +func (c *Clientset) SecuresourcemanagerV1alpha1() securesourcemanagerv1alpha1.SecuresourcemanagerV1alpha1Interface { + return c.securesourcemanagerV1alpha1 +} + // SecuritycenterV1alpha1 retrieves the SecuritycenterV1alpha1Client func (c *Clientset) SecuritycenterV1alpha1() securitycenterv1alpha1.SecuritycenterV1alpha1Interface { return c.securitycenterV1alpha1 @@ -1395,6 +1403,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.securesourcemanagerV1alpha1, err = securesourcemanagerv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.securitycenterV1alpha1, err = securitycenterv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -1592,6 +1604,7 @@ func New(c rest.Interface) *Clientset { cs.resourcemanagerV1beta1 = resourcemanagerv1beta1.New(c) cs.runV1beta1 = runv1beta1.New(c) cs.secretmanagerV1beta1 = secretmanagerv1beta1.New(c) + cs.securesourcemanagerV1alpha1 = securesourcemanagerv1alpha1.New(c) cs.securitycenterV1alpha1 = securitycenterv1alpha1.New(c) cs.servicedirectoryV1beta1 = servicedirectoryv1beta1.New(c) cs.servicenetworkingV1beta1 = servicenetworkingv1beta1.New(c) diff --git a/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go b/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go index 6eb1b3fc0e..5c1769388f 100644 --- a/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/clients/generated/client/clientset/versioned/fake/clientset_generated.go @@ -215,6 +215,8 @@ import ( fakerunv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/run/v1beta1/fake" secretmanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/secretmanager/v1beta1" fakesecretmanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/secretmanager/v1beta1/fake" + securesourcemanagerv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1" + fakesecuresourcemanagerv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake" securitycenterv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securitycenter/v1alpha1" fakesecuritycenterv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securitycenter/v1alpha1/fake" servicedirectoryv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/servicedirectory/v1beta1" @@ -792,6 +794,11 @@ func (c *Clientset) SecretmanagerV1beta1() secretmanagerv1beta1.SecretmanagerV1b return &fakesecretmanagerv1beta1.FakeSecretmanagerV1beta1{Fake: &c.Fake} } +// SecuresourcemanagerV1alpha1 retrieves the SecuresourcemanagerV1alpha1Client +func (c *Clientset) SecuresourcemanagerV1alpha1() securesourcemanagerv1alpha1.SecuresourcemanagerV1alpha1Interface { + return &fakesecuresourcemanagerv1alpha1.FakeSecuresourcemanagerV1alpha1{Fake: &c.Fake} +} + // SecuritycenterV1alpha1 retrieves the SecuritycenterV1alpha1Client func (c *Clientset) SecuritycenterV1alpha1() securitycenterv1alpha1.SecuritycenterV1alpha1Interface { return &fakesecuritycenterv1alpha1.FakeSecuritycenterV1alpha1{Fake: &c.Fake} diff --git a/pkg/clients/generated/client/clientset/versioned/fake/register.go b/pkg/clients/generated/client/clientset/versioned/fake/register.go index 12690b74ab..e76c6b0cec 100644 --- a/pkg/clients/generated/client/clientset/versioned/fake/register.go +++ b/pkg/clients/generated/client/clientset/versioned/fake/register.go @@ -118,6 +118,7 @@ import ( resourcemanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/resourcemanager/v1beta1" runv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/run/v1beta1" secretmanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/secretmanager/v1beta1" + securesourcemanagerv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securesourcemanager/v1alpha1" securitycenterv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securitycenter/v1alpha1" servicedirectoryv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/servicedirectory/v1beta1" servicenetworkingv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/servicenetworking/v1beta1" @@ -245,6 +246,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ resourcemanagerv1beta1.AddToScheme, runv1beta1.AddToScheme, secretmanagerv1beta1.AddToScheme, + securesourcemanagerv1alpha1.AddToScheme, securitycenterv1alpha1.AddToScheme, servicedirectoryv1beta1.AddToScheme, servicenetworkingv1beta1.AddToScheme, diff --git a/pkg/clients/generated/client/clientset/versioned/scheme/register.go b/pkg/clients/generated/client/clientset/versioned/scheme/register.go index a27bed114f..652c5dbd72 100644 --- a/pkg/clients/generated/client/clientset/versioned/scheme/register.go +++ b/pkg/clients/generated/client/clientset/versioned/scheme/register.go @@ -118,6 +118,7 @@ import ( resourcemanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/resourcemanager/v1beta1" runv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/run/v1beta1" secretmanagerv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/secretmanager/v1beta1" + securesourcemanagerv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securesourcemanager/v1alpha1" securitycenterv1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securitycenter/v1alpha1" servicedirectoryv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/servicedirectory/v1beta1" servicenetworkingv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/servicenetworking/v1beta1" @@ -245,6 +246,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ resourcemanagerv1beta1.AddToScheme, runv1beta1.AddToScheme, secretmanagerv1beta1.AddToScheme, + securesourcemanagerv1alpha1.AddToScheme, securitycenterv1alpha1.AddToScheme, servicedirectoryv1beta1.AddToScheme, servicenetworkingv1beta1.AddToScheme, diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/doc.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/doc.go new file mode 100644 index 0000000000..61f2499ab1 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/doc.go @@ -0,0 +1,23 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/doc.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..7a39491606 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/doc.go @@ -0,0 +1,23 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go new file mode 100644 index 0000000000..a068e3baf5 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanager_client.go @@ -0,0 +1,43 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeSecuresourcemanagerV1alpha1 struct { + *testing.Fake +} + +func (c *FakeSecuresourcemanagerV1alpha1) SecureSourceManagerInstances(namespace string) v1alpha1.SecureSourceManagerInstanceInterface { + return &FakeSecureSourceManagerInstances{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSecuresourcemanagerV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerinstance.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerinstance.go new file mode 100644 index 0000000000..72fe6e8f28 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/fake/fake_securesourcemanagerinstance.go @@ -0,0 +1,144 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securesourcemanager/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSecureSourceManagerInstances implements SecureSourceManagerInstanceInterface +type FakeSecureSourceManagerInstances struct { + Fake *FakeSecuresourcemanagerV1alpha1 + ns string +} + +var securesourcemanagerinstancesResource = v1alpha1.SchemeGroupVersion.WithResource("securesourcemanagerinstances") + +var securesourcemanagerinstancesKind = v1alpha1.SchemeGroupVersion.WithKind("SecureSourceManagerInstance") + +// Get takes name of the secureSourceManagerInstance, and returns the corresponding secureSourceManagerInstance object, and an error if there is any. +func (c *FakeSecureSourceManagerInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(securesourcemanagerinstancesResource, c.ns, name), &v1alpha1.SecureSourceManagerInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerInstance), err +} + +// List takes label and field selectors, and returns the list of SecureSourceManagerInstances that match those selectors. +func (c *FakeSecureSourceManagerInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SecureSourceManagerInstanceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(securesourcemanagerinstancesResource, securesourcemanagerinstancesKind, c.ns, opts), &v1alpha1.SecureSourceManagerInstanceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SecureSourceManagerInstanceList{ListMeta: obj.(*v1alpha1.SecureSourceManagerInstanceList).ListMeta} + for _, item := range obj.(*v1alpha1.SecureSourceManagerInstanceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested secureSourceManagerInstances. +func (c *FakeSecureSourceManagerInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(securesourcemanagerinstancesResource, c.ns, opts)) + +} + +// Create takes the representation of a secureSourceManagerInstance and creates it. Returns the server's representation of the secureSourceManagerInstance, and an error, if there is any. +func (c *FakeSecureSourceManagerInstances) Create(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.CreateOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(securesourcemanagerinstancesResource, c.ns, secureSourceManagerInstance), &v1alpha1.SecureSourceManagerInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerInstance), err +} + +// Update takes the representation of a secureSourceManagerInstance and updates it. Returns the server's representation of the secureSourceManagerInstance, and an error, if there is any. +func (c *FakeSecureSourceManagerInstances) Update(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(securesourcemanagerinstancesResource, c.ns, secureSourceManagerInstance), &v1alpha1.SecureSourceManagerInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerInstance), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeSecureSourceManagerInstances) UpdateStatus(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerInstance, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(securesourcemanagerinstancesResource, "status", c.ns, secureSourceManagerInstance), &v1alpha1.SecureSourceManagerInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerInstance), err +} + +// Delete takes name of the secureSourceManagerInstance and deletes it. Returns an error if one occurs. +func (c *FakeSecureSourceManagerInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(securesourcemanagerinstancesResource, c.ns, name, opts), &v1alpha1.SecureSourceManagerInstance{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSecureSourceManagerInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(securesourcemanagerinstancesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SecureSourceManagerInstanceList{}) + return err +} + +// Patch applies the patch and returns the patched secureSourceManagerInstance. +func (c *FakeSecureSourceManagerInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SecureSourceManagerInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(securesourcemanagerinstancesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SecureSourceManagerInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SecureSourceManagerInstance), err +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..eb08db341c --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/generated_expansion.go @@ -0,0 +1,24 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package v1alpha1 + +type SecureSourceManagerInstanceExpansion interface{} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go new file mode 100644 index 0000000000..a636b1630c --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanager_client.go @@ -0,0 +1,110 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securesourcemanager/v1alpha1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type SecuresourcemanagerV1alpha1Interface interface { + RESTClient() rest.Interface + SecureSourceManagerInstancesGetter +} + +// SecuresourcemanagerV1alpha1Client is used to interact with features provided by the securesourcemanager.cnrm.cloud.google.com group. +type SecuresourcemanagerV1alpha1Client struct { + restClient rest.Interface +} + +func (c *SecuresourcemanagerV1alpha1Client) SecureSourceManagerInstances(namespace string) SecureSourceManagerInstanceInterface { + return newSecureSourceManagerInstances(c, namespace) +} + +// NewForConfig creates a new SecuresourcemanagerV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*SecuresourcemanagerV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new SecuresourcemanagerV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SecuresourcemanagerV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &SecuresourcemanagerV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new SecuresourcemanagerV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SecuresourcemanagerV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SecuresourcemanagerV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *SecuresourcemanagerV1alpha1Client { + return &SecuresourcemanagerV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SecuresourcemanagerV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerinstance.go b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerinstance.go new file mode 100644 index 0000000000..141ddd8a40 --- /dev/null +++ b/pkg/clients/generated/client/clientset/versioned/typed/securesourcemanager/v1alpha1/securesourcemanagerinstance.go @@ -0,0 +1,198 @@ +// 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. + +// *** 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! + +// Code generated by main. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/securesourcemanager/v1alpha1" + scheme "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// SecureSourceManagerInstancesGetter has a method to return a SecureSourceManagerInstanceInterface. +// A group's client should implement this interface. +type SecureSourceManagerInstancesGetter interface { + SecureSourceManagerInstances(namespace string) SecureSourceManagerInstanceInterface +} + +// SecureSourceManagerInstanceInterface has methods to work with SecureSourceManagerInstance resources. +type SecureSourceManagerInstanceInterface interface { + Create(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.CreateOptions) (*v1alpha1.SecureSourceManagerInstance, error) + Update(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerInstance, error) + UpdateStatus(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (*v1alpha1.SecureSourceManagerInstance, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.SecureSourceManagerInstance, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SecureSourceManagerInstanceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SecureSourceManagerInstance, err error) + SecureSourceManagerInstanceExpansion +} + +// secureSourceManagerInstances implements SecureSourceManagerInstanceInterface +type secureSourceManagerInstances struct { + client rest.Interface + ns string +} + +// newSecureSourceManagerInstances returns a SecureSourceManagerInstances +func newSecureSourceManagerInstances(c *SecuresourcemanagerV1alpha1Client, namespace string) *secureSourceManagerInstances { + return &secureSourceManagerInstances{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the secureSourceManagerInstance, and returns the corresponding secureSourceManagerInstance object, and an error if there is any. +func (c *secureSourceManagerInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + result = &v1alpha1.SecureSourceManagerInstance{} + err = c.client.Get(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SecureSourceManagerInstances that match those selectors. +func (c *secureSourceManagerInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SecureSourceManagerInstanceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SecureSourceManagerInstanceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested secureSourceManagerInstances. +func (c *secureSourceManagerInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a secureSourceManagerInstance and creates it. Returns the server's representation of the secureSourceManagerInstance, and an error, if there is any. +func (c *secureSourceManagerInstances) Create(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.CreateOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + result = &v1alpha1.SecureSourceManagerInstance{} + err = c.client.Post(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerInstance). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a secureSourceManagerInstance and updates it. Returns the server's representation of the secureSourceManagerInstance, and an error, if there is any. +func (c *secureSourceManagerInstances) Update(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + result = &v1alpha1.SecureSourceManagerInstance{} + err = c.client.Put(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + Name(secureSourceManagerInstance.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerInstance). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *secureSourceManagerInstances) UpdateStatus(ctx context.Context, secureSourceManagerInstance *v1alpha1.SecureSourceManagerInstance, opts v1.UpdateOptions) (result *v1alpha1.SecureSourceManagerInstance, err error) { + result = &v1alpha1.SecureSourceManagerInstance{} + err = c.client.Put(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + Name(secureSourceManagerInstance.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(secureSourceManagerInstance). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the secureSourceManagerInstance and deletes it. Returns an error if one occurs. +func (c *secureSourceManagerInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *secureSourceManagerInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched secureSourceManagerInstance. +func (c *secureSourceManagerInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SecureSourceManagerInstance, err error) { + result = &v1alpha1.SecureSourceManagerInstance{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("securesourcemanagerinstances"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +}