diff --git a/PROJECT b/PROJECT index 1f3753a4..7cd4aaf5 100644 --- a/PROJECT +++ b/PROJECT @@ -24,6 +24,17 @@ resources: webhooks: validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: servicebinding.io + kind: ServiceBinding + path: github.com/servicebinding/runtime/apis/v1 + version: v1 + webhooks: + validation: true + webhookVersion: v1 - api: crdVersion: v1 domain: servicebinding.io @@ -39,4 +50,13 @@ resources: webhooks: validation: true webhookVersion: v1 +- api: + crdVersion: v1 + domain: servicebinding.io + kind: ClusterWorkloadResourceMapping + path: github.com/servicebinding/runtime/apis/v1 + version: v1 + webhooks: + validation: true + webhookVersion: v1 version: "3" diff --git a/README.md b/README.md index 6863f017..f596f8f7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![codecov](https://codecov.io/gh/servicebinding/runtime/branch/main/graph/badge.svg?token=D2Hs4MIXBZ)](https://codecov.io/gh/servicebinding/runtime) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -Reference implementation of the [ServiceBinding.io](https://servicebinding.io) [1.0 spec](https://servicebinding.io/spec/core/1.0.0/). The full specification is implemented, please open an issue for any discrepancies. +Reference implementation of the [ServiceBinding.io](https://servicebinding.io) [1.1 spec](https://servicebinding.io/spec/core/1.1.0/), along with [1.0](https://servicebinding.io/spec/core/1.0.0/). The full specification is implemented, please open an issue for any discrepancies. - [Getting Started](#getting-started) - [Deploy a released build](#deploy-a-released-build) @@ -77,9 +77,9 @@ Samples are located in the [samples directory](./samples), including: ## Supported Services -Kubernetes defines no provisioned services by default, however, `Secret`s may be [directly referenced](https://servicebinding.io/spec/core/1.0.0/#direct-secret-reference). +Kubernetes defines no provisioned services by default, however, `Secret`s may be [directly referenced](https://servicebinding.io/spec/core/1.1.0/#direct-secret-reference). -Additional services can be supported dynamically by [defining a `ClusterRole`](https://servicebinding.io/spec/core/1.0.0/#considerations-for-role-based-access-control-rbac). +Additional services can be supported dynamically by [defining a `ClusterRole`](https://servicebinding.io/spec/core/1.1.0/#considerations-for-role-based-access-control-rbac). ## Supported Workloads @@ -92,11 +92,11 @@ Support for the built-in k8s workload resource is pre-configured including: - batch `Job` (since Jobs are immutable, the ServiceBinding must be defined and service resolved before the job is created) - core `ReplicationController` -Additional workloads can be supported dynamically by [defining a `ClusterRole`](https://servicebinding.io/spec/core/1.0.0/#considerations-for-role-based-access-control-rbac-1) and if not PodSpecable, a [`ClusterWorkloadResourceMapping`](https://servicebinding.io/spec/core/1.0.0/#workload-resource-mapping). +Additional workloads can be supported dynamically by [defining a `ClusterRole`](https://servicebinding.io/spec/core/1.1.0/#considerations-for-role-based-access-control-rbac-1) and if not PodSpecable, a [`ClusterWorkloadResourceMapping`](https://servicebinding.io/spec/core/1.1.0/#workload-resource-mapping). ## Architecture -The [Service Binding for Kubernetes Specification](https://servicebinding.io/spec/core/1.0.0/) defines the shape of [Provisioned Services](https://servicebinding.io/spec/core/1.0.0/#provisioned-service), and how the `Secret` is [projected into a workload](https://servicebinding.io/spec/core/1.0.0/#workload-projection). The spec says less (intentionally) about how this happens. +The [Service Binding for Kubernetes Specification](https://servicebinding.io/spec/core/1.1.0/) defines the shape of [Provisioned Services](https://servicebinding.io/spec/core/1.1.0/#provisioned-service), and how the `Secret` is [projected into a workload](https://servicebinding.io/spec/core/1.1.0/#workload-projection). The spec says less (intentionally) about how this happens. Both a controller and mutating admission webhook are used to project a `Secret` defined by the service referenced by the `ServiceBinding` resource into the workloads referenced. The controller is used to process `ServiceBinding`s by resolving services, projecting workloads and updating the status. The webhook is used to prevent removal of the workload projection, projecting workload on create, and a notification trigger for `ServiceBinding`s the controller should process. diff --git a/apis/v1/clusterworkloadresourcemapping_conversion.go b/apis/v1/clusterworkloadresourcemapping_conversion.go new file mode 100644 index 00000000..389b4bfc --- /dev/null +++ b/apis/v1/clusterworkloadresourcemapping_conversion.go @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Original Authors + * + * 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 + * + * https://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 v1 + +import "sigs.k8s.io/controller-runtime/pkg/conversion" + +var _ conversion.Hub = (*ClusterWorkloadResourceMapping)(nil) + +// Hub for conversion +func (r *ClusterWorkloadResourceMapping) Hub() {} diff --git a/apis/v1beta1/clusterworkloadresourcemapping_test.go b/apis/v1/clusterworkloadresourcemapping_test.go similarity index 99% rename from apis/v1beta1/clusterworkloadresourcemapping_test.go rename to apis/v1/clusterworkloadresourcemapping_test.go index 1a7d347b..9818c40a 100644 --- a/apis/v1beta1/clusterworkloadresourcemapping_test.go +++ b/apis/v1/clusterworkloadresourcemapping_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import ( "testing" @@ -121,7 +121,7 @@ func TestClusterWorkloadResourceMappingDefault(t *testing.T) { Spec: ClusterWorkloadResourceMappingSpec{ Versions: []ClusterWorkloadResourceMappingTemplate{ { - Version: "v1beta1", + Version: "v1", Annotations: ".metadata.annotations", Containers: []ClusterWorkloadResourceMappingContainer{ { @@ -145,7 +145,7 @@ func TestClusterWorkloadResourceMappingDefault(t *testing.T) { Spec: ClusterWorkloadResourceMappingSpec{ Versions: []ClusterWorkloadResourceMappingTemplate{ { - Version: "v1beta1", + Version: "v1", Annotations: ".metadata.annotations", Containers: []ClusterWorkloadResourceMappingContainer{ { diff --git a/apis/v1/clusterworkloadresourcemapping_types.go b/apis/v1/clusterworkloadresourcemapping_types.go new file mode 100644 index 00000000..05e7128a --- /dev/null +++ b/apis/v1/clusterworkloadresourcemapping_types.go @@ -0,0 +1,91 @@ +/* + * Copyright 2021 Original Authors + * + * 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 + * + * https://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 v1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// ClusterWorkloadResourceMappingTemplate defines the mapping for a specific version of an workload resource to a +// logical PodTemplateSpec-like structure. +type ClusterWorkloadResourceMappingTemplate struct { + // Version is the version of the workload resource that this mapping is for. + Version string `json:"version"` + // Annotations is a Restricted JSONPath that references the annotations map within the workload resource. These + // annotations must end up in the resulting Pod, and are generally not the workload resource's annotations. + // Defaults to `.spec.template.metadata.annotations`. + Annotations string `json:"annotations,omitempty"` + // Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to + // mappings appropriate for a PodSpecable resource. + Containers []ClusterWorkloadResourceMappingContainer `json:"containers,omitempty"` + // Volumes is a Restricted JSONPath that references the slice of volumes within the workload resource. Defaults to + // `.spec.template.spec.volumes`. + Volumes string `json:"volumes,omitempty"` +} + +// ClusterWorkloadResourceMappingContainer defines the mapping for a specific fragment of an workload resource +// to a Container-like structure. +// +// Each mapping defines exactly one path that may match multiple container-like fragments within the workload +// resource. For each object matching the path the name, env and volumeMounts expressions are resolved to find those +// structures. +type ClusterWorkloadResourceMappingContainer struct { + // Path is the JSONPath within the workload resource that matches an existing fragment that is container-like. + Path string `json:"path"` + // Name is a Restricted JSONPath that references the name of the container with the container-like workload resource + // fragment. If not defined, container name filtering is ignored. + Name string `json:"name,omitempty"` + // Env is a Restricted JSONPath that references the slice of environment variables for the container with the + // container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + // to `.envs`. + Env string `json:"env,omitempty"` + // VolumeMounts is a Restricted JSONPath that references the slice of volume mounts for the container with the + // container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + // to `.volumeMounts`. + VolumeMounts string `json:"volumeMounts,omitempty"` +} + +// ClusterWorkloadResourceMappingSpec defines the desired state of ClusterWorkloadResourceMapping +type ClusterWorkloadResourceMappingSpec struct { + // Versions is the collection of versions for a given resource, with mappings. + Versions []ClusterWorkloadResourceMappingTemplate `json:"versions,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` + +// ClusterWorkloadResourceMapping is the Schema for the clusterworkloadresourcemappings API +type ClusterWorkloadResourceMapping struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ClusterWorkloadResourceMappingSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// ClusterWorkloadResourceMappingList contains a list of ClusterWorkloadResourceMapping +type ClusterWorkloadResourceMappingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []ClusterWorkloadResourceMapping `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ClusterWorkloadResourceMapping{}, &ClusterWorkloadResourceMappingList{}) +} diff --git a/apis/v1/clusterworkloadresourcemapping_webhook.go b/apis/v1/clusterworkloadresourcemapping_webhook.go new file mode 100644 index 00000000..f083710b --- /dev/null +++ b/apis/v1/clusterworkloadresourcemapping_webhook.go @@ -0,0 +1,181 @@ +/* +Copyright 2021 the original author or authors. + +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 v1 + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/client-go/util/jsonpath" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (r *ClusterWorkloadResourceMapping) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +var _ webhook.Defaulter = &ClusterWorkloadResourceMapping{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (r *ClusterWorkloadResourceMapping) Default() { + for i := range r.Spec.Versions { + r.Spec.Versions[i].Default() + } +} + +// Default applies values that are appropriate for a PodSpecable resource +func (r *ClusterWorkloadResourceMappingTemplate) Default() { + if r.Annotations == "" { + r.Annotations = ".spec.template.metadata.annotations" + } + if len(r.Containers) == 0 { + r.Containers = []ClusterWorkloadResourceMappingContainer{ + { + Path: ".spec.template.spec.initContainers[*]", + Name: ".name", + }, + { + Path: ".spec.template.spec.containers[*]", + Name: ".name", + }, + } + } + for i := range r.Containers { + c := &r.Containers[i] + if c.Env == "" { + c.Env = ".env" + } + if c.VolumeMounts == "" { + c.VolumeMounts = ".volumeMounts" + } + } + if r.Volumes == "" { + r.Volumes = ".spec.template.spec.volumes" + } +} + +//+kubebuilder:webhook:path=/validate-servicebinding-io-v1-clusterworkloadresourcemapping,mutating=false,failurePolicy=fail,sideEffects=None,groups=servicebinding.io,resources=clusterworkloadresourcemappings,verbs=create;update,versions=v1,name=v1.clusterworkloadresourcemappings.servicebinding.io,admissionReviewVersions={v1,v1beta1} + +var _ webhook.Validator = &ClusterWorkloadResourceMapping{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (r *ClusterWorkloadResourceMapping) ValidateCreate() (admission.Warnings, error) { + r.Default() + return nil, r.validate().ToAggregate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (r *ClusterWorkloadResourceMapping) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + r.Default() + // TODO(user): check for immutable fields, if any + return nil, r.validate().ToAggregate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (r *ClusterWorkloadResourceMapping) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (r *ClusterWorkloadResourceMapping) validate() field.ErrorList { + errs := field.ErrorList{} + + versions := map[string]int{} + for i := range r.Spec.Versions { + // check for duplicate versions + if p, ok := versions[r.Spec.Versions[i].Version]; ok { + errs = append(errs, field.Duplicate(field.NewPath("spec", "versions", fmt.Sprintf("[%d, %d]", p, i), "version"), r.Spec.Versions[i].Version)) + } + versions[r.Spec.Versions[i].Version] = i + errs = append(errs, r.Spec.Versions[i].validate(field.NewPath("spec", "versions").Index(i))...) + } + + return errs +} + +func (r *ClusterWorkloadResourceMappingTemplate) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if r.Version == "" { + errs = append(errs, field.Required(fldPath.Child("version"), "")) + } + errs = append(errs, validateRestrictedJsonPath(r.Annotations, fldPath.Child("annotations"))...) + errs = append(errs, validateRestrictedJsonPath(r.Volumes, fldPath.Child("volumes"))...) + for i := range r.Containers { + errs = append(errs, r.Containers[i].validate(fldPath.Child("containers").Index(i))...) + } + + return errs +} + +func (r *ClusterWorkloadResourceMappingContainer) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + errs = append(errs, validateJsonPath(r.Path, fldPath.Child("path"))...) + if r.Name != "" { + // name is optional + errs = append(errs, validateRestrictedJsonPath(r.Name, fldPath.Child("name"))...) + } + errs = append(errs, validateRestrictedJsonPath(r.Env, fldPath.Child("env"))...) + errs = append(errs, validateRestrictedJsonPath(r.VolumeMounts, fldPath.Child("volumeMounts"))...) + + return errs +} + +func validateJsonPath(expression string, fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if p, err := jsonpath.Parse("", fmt.Sprintf("{%s}", expression)); err != nil { + errs = append(errs, field.Invalid(fldPath, expression, err.Error())) + } else { + if len(p.Root.Nodes) != 1 { + errs = append(errs, field.Invalid(fldPath, expression, "too many root nodes")) + } + } + + return errs +} + +func validateRestrictedJsonPath(expression string, fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if p, err := jsonpath.Parse("", fmt.Sprintf("{%s}", expression)); err != nil { + errs = append(errs, field.Invalid(fldPath, expression, err.Error())) + } else { + if len(p.Root.Nodes) != 1 { + errs = append(errs, field.Invalid(fldPath, expression, "too many root nodes")) + } + // only allow jsonpath.NodeField nodes + nodes := p.Root.Nodes + for i := 0; i < len(nodes); i++ { + switch n := nodes[i].(type) { + case *jsonpath.ListNode: + nodes = append(nodes, n.Nodes...) + case *jsonpath.FieldNode: + continue + default: + errs = append(errs, field.Invalid(fldPath, expression, fmt.Sprintf("unsupported node: %s", n))) + } + } + } + + return errs +} diff --git a/apis/v1/groupversion_info.go b/apis/v1/groupversion_info.go new file mode 100644 index 00000000..7af97d2f --- /dev/null +++ b/apis/v1/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2022 the original author or authors. + +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 v1 contains API Schema definitions for the servicebinding.io v1 API group +// +kubebuilder:object:generate=true +// +groupName=servicebinding.io +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "servicebinding.io", Version: "v1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/v1/servicebinding_conversion.go b/apis/v1/servicebinding_conversion.go new file mode 100644 index 00000000..a9cfe8f3 --- /dev/null +++ b/apis/v1/servicebinding_conversion.go @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Original Authors + * + * 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 + * + * https://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 v1 + +import ( + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +var _ conversion.Hub = (*ServiceBinding)(nil) + +// Hub for conversion +func (r *ServiceBinding) Hub() {} diff --git a/apis/v1beta1/servicebinding_lifecycle.go b/apis/v1/servicebinding_lifecycle.go similarity index 96% rename from apis/v1beta1/servicebinding_lifecycle.go rename to apis/v1/servicebinding_lifecycle.go index 74042d9c..66246842 100644 --- a/apis/v1beta1/servicebinding_lifecycle.go +++ b/apis/v1/servicebinding_lifecycle.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 contains API Schema definitions for the servicebinding.io v1beta1 API group +// Package v1 contains API Schema definitions for the servicebinding.io v1 API group // +kubebuilder:object:generate=true // +groupName=servicebinding.io -package v1beta1 +package v1 import ( "github.com/vmware-labs/reconciler-runtime/apis" diff --git a/apis/v1beta1/servicebinding_test.go b/apis/v1/servicebinding_test.go similarity index 99% rename from apis/v1beta1/servicebinding_test.go rename to apis/v1/servicebinding_test.go index 74a650c1..2138b69a 100644 --- a/apis/v1beta1/servicebinding_test.go +++ b/apis/v1/servicebinding_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import ( "testing" @@ -421,7 +421,7 @@ func TestServiceBindingValidate_Immutable(t *testing.T) { { Type: field.ErrorTypeInternal, Field: "", - Detail: "old object must be of type v1beta1.ServiceBinding", + Detail: "old object must be of type v1.ServiceBinding", }, }, }, diff --git a/apis/v1/servicebinding_types.go b/apis/v1/servicebinding_types.go new file mode 100644 index 00000000..cebf2588 --- /dev/null +++ b/apis/v1/servicebinding_types.go @@ -0,0 +1,124 @@ +/* + * Copyright 2020 Original Authors + * + * 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 + * + * https://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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ServiceBindingWorkloadReference defines a subset of corev1.ObjectReference with extensions +type ServiceBindingWorkloadReference struct { + // API version of the referent. + APIVersion string `json:"apiVersion"` + // Kind of the referent. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` + // Name of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name,omitempty"` + // Selector is a query that selects the workload or workloads to bind the service to + Selector *metav1.LabelSelector `json:"selector,omitempty"` + // Containers describes which containers in a Pod should be bound to + Containers []string `json:"containers,omitempty"` +} + +// ServiceBindingServiceReference defines a subset of corev1.ObjectReference +type ServiceBindingServiceReference struct { + // API version of the referent. + APIVersion string `json:"apiVersion"` + // Kind of the referent. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` + // Name of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name"` +} + +// ServiceBindingSecretReference defines a mirror of corev1.LocalObjectReference +type ServiceBindingSecretReference struct { + // Name of the referent secret. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name"` +} + +// EnvMapping defines a mapping from the value of a Secret entry to an environment variable +type EnvMapping struct { + // Name is the name of the environment variable + Name string `json:"name"` + // Key is the key in the Secret that will be exposed + Key string `json:"key"` +} + +// ServiceBindingSpec defines the desired state of ServiceBinding +type ServiceBindingSpec struct { + // Name is the name of the service as projected into the workload container. Defaults to .metadata.name. + Name string `json:"name,omitempty"` + // Type is the type of the service as projected into the workload container + Type string `json:"type,omitempty"` + // Provider is the provider of the service as projected into the workload container + Provider string `json:"provider,omitempty"` + // Workload is a reference to an object + Workload ServiceBindingWorkloadReference `json:"workload"` + // Service is a reference to an object that fulfills the ProvisionedService duck type + Service ServiceBindingServiceReference `json:"service"` + // Env is the collection of mappings from Secret entries to environment variables + Env []EnvMapping `json:"env,omitempty"` +} + +// ServiceBindingStatus defines the observed state of ServiceBinding +type ServiceBindingStatus struct { + // ObservedGeneration is the 'Generation' of the ServiceBinding that + // was last processed by the controller. + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions are the conditions of this ServiceBinding + Conditions []metav1.Condition `json:"conditions,omitempty"` + + // Binding exposes the projected secret for this ServiceBinding + Binding *ServiceBindingSecretReference `json:"binding,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Secret",type=string,JSONPath=`.status.binding.name` +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` +// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason` +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` + +// ServiceBinding is the Schema for the servicebindings API +type ServiceBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ServiceBindingSpec `json:"spec,omitempty"` + Status ServiceBindingStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ServiceBindingList contains a list of ServiceBinding +type ServiceBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []ServiceBinding `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ServiceBinding{}, &ServiceBindingList{}) +} diff --git a/apis/v1/servicebinding_webhook.go b/apis/v1/servicebinding_webhook.go new file mode 100644 index 00000000..d2ba01c5 --- /dev/null +++ b/apis/v1/servicebinding_webhook.go @@ -0,0 +1,174 @@ +/* +Copyright 2021 the original author or authors. + +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 v1 + +import ( + "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/conversion" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (r *ServiceBinding) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +var _ webhook.Defaulter = &ServiceBinding{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (r *ServiceBinding) Default() { + if r.Spec.Name == "" { + r.Spec.Name = r.Name + } +} + +//+kubebuilder:webhook:path=/validate-servicebinding-io-v1-servicebinding,mutating=false,failurePolicy=fail,sideEffects=None,groups=servicebinding.io,resources=servicebindings,verbs=create;update,versions=v1,name=v1.servicebindings.servicebinding.io,admissionReviewVersions={v1,v1beta1} + +var _ webhook.Validator = &ServiceBinding{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (r *ServiceBinding) ValidateCreate() (admission.Warnings, error) { + r.Default() + return nil, r.validate().ToAggregate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (r *ServiceBinding) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + r.Default() + + errs := field.ErrorList{} + + // check immutable fields + var ro *ServiceBinding + if o, ok := old.(*ServiceBinding); ok { + ro = o + } else if o, ok := old.(conversion.Convertible); ok { + ro = &ServiceBinding{} + if err := o.ConvertTo(ro); err != nil { + return nil, err + } + } else { + errs = append(errs, + field.InternalError(nil, fmt.Errorf("old object must be of type v1.ServiceBinding")), + ) + } + if len(errs) == 0 { + if r.Spec.Workload.APIVersion != ro.Spec.Workload.APIVersion { + errs = append(errs, + field.Forbidden(field.NewPath("spec", "workload", "apiVersion"), "Workload apiVersion is immutable. Delete and recreate the ServiceBinding to update."), + ) + } + if r.Spec.Workload.Kind != ro.Spec.Workload.Kind { + errs = append(errs, + field.Forbidden(field.NewPath("spec", "workload", "kind"), "Workload kind is immutable. Delete and recreate the ServiceBinding to update."), + ) + } + } + + // validate new object + errs = append(errs, r.validate()...) + + return nil, errs.ToAggregate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (r *ServiceBinding) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (r *ServiceBinding) validate() field.ErrorList { + errs := field.ErrorList{} + + errs = append(errs, r.Spec.validate(field.NewPath("spec"))...) + + return errs +} + +func (r *ServiceBindingSpec) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if r.Name == "" { + errs = append(errs, field.Required(fldPath.Child("name"), "")) + } + errs = append(errs, r.Service.validate(fldPath.Child("service"))...) + errs = append(errs, r.Workload.validate(fldPath.Child("workload"))...) + for i := range r.Env { + errs = append(errs, r.Env[i].validate(fldPath.Child("env").Index(i))...) + } + + return errs +} + +func (r *ServiceBindingServiceReference) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if r.APIVersion == "" { + errs = append(errs, field.Required(fldPath.Child("apiVersion"), "")) + } + if r.Kind == "" { + errs = append(errs, field.Required(fldPath.Child("kind"), "")) + } + if r.Name == "" { + errs = append(errs, field.Required(fldPath.Child("name"), "")) + } + + return errs +} + +func (r *ServiceBindingWorkloadReference) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if r.APIVersion == "" { + errs = append(errs, field.Required(fldPath.Child("apiVersion"), "")) + } + if r.Kind == "" { + errs = append(errs, field.Required(fldPath.Child("kind"), "")) + } + if r.Name == "" && r.Selector == nil { + errs = append(errs, field.Required(fldPath.Child("[name, selector]"), "expected exactly one, got neither")) + } + if r.Name != "" && r.Selector != nil { + errs = append(errs, field.Required(fldPath.Child("[name, selector]"), "expected exactly one, got both")) + } + if r.Selector != nil { + if _, err := metav1.LabelSelectorAsSelector(r.Selector); err != nil { + errs = append(errs, field.Invalid(fldPath.Child("selector"), r.Selector, err.Error())) + } + } + + return errs +} + +func (r *EnvMapping) validate(fldPath *field.Path) field.ErrorList { + errs := field.ErrorList{} + + if r.Name == "" { + errs = append(errs, field.Required(fldPath.Child("name"), "")) + } + if r.Key == "" { + errs = append(errs, field.Required(fldPath.Child("key"), "")) + } + + return errs +} diff --git a/apis/v1/zz_generated.deepcopy.go b/apis/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000..0cd0edb6 --- /dev/null +++ b/apis/v1/zz_generated.deepcopy.go @@ -0,0 +1,319 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2022 the original author or authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterWorkloadResourceMapping) DeepCopyInto(out *ClusterWorkloadResourceMapping) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMapping. +func (in *ClusterWorkloadResourceMapping) DeepCopy() *ClusterWorkloadResourceMapping { + if in == nil { + return nil + } + out := new(ClusterWorkloadResourceMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterWorkloadResourceMapping) 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 *ClusterWorkloadResourceMappingContainer) DeepCopyInto(out *ClusterWorkloadResourceMappingContainer) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingContainer. +func (in *ClusterWorkloadResourceMappingContainer) DeepCopy() *ClusterWorkloadResourceMappingContainer { + if in == nil { + return nil + } + out := new(ClusterWorkloadResourceMappingContainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterWorkloadResourceMappingList) DeepCopyInto(out *ClusterWorkloadResourceMappingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterWorkloadResourceMapping, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingList. +func (in *ClusterWorkloadResourceMappingList) DeepCopy() *ClusterWorkloadResourceMappingList { + if in == nil { + return nil + } + out := new(ClusterWorkloadResourceMappingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterWorkloadResourceMappingList) 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 *ClusterWorkloadResourceMappingSpec) DeepCopyInto(out *ClusterWorkloadResourceMappingSpec) { + *out = *in + if in.Versions != nil { + in, out := &in.Versions, &out.Versions + *out = make([]ClusterWorkloadResourceMappingTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingSpec. +func (in *ClusterWorkloadResourceMappingSpec) DeepCopy() *ClusterWorkloadResourceMappingSpec { + if in == nil { + return nil + } + out := new(ClusterWorkloadResourceMappingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterWorkloadResourceMappingTemplate) DeepCopyInto(out *ClusterWorkloadResourceMappingTemplate) { + *out = *in + if in.Containers != nil { + in, out := &in.Containers, &out.Containers + *out = make([]ClusterWorkloadResourceMappingContainer, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingTemplate. +func (in *ClusterWorkloadResourceMappingTemplate) DeepCopy() *ClusterWorkloadResourceMappingTemplate { + if in == nil { + return nil + } + out := new(ClusterWorkloadResourceMappingTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvMapping) DeepCopyInto(out *EnvMapping) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvMapping. +func (in *EnvMapping) DeepCopy() *EnvMapping { + if in == nil { + return nil + } + out := new(EnvMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceBinding) DeepCopyInto(out *ServiceBinding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBinding. +func (in *ServiceBinding) DeepCopy() *ServiceBinding { + if in == nil { + return nil + } + out := new(ServiceBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceBinding) 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 *ServiceBindingList) DeepCopyInto(out *ServiceBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ServiceBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingList. +func (in *ServiceBindingList) DeepCopy() *ServiceBindingList { + if in == nil { + return nil + } + out := new(ServiceBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceBindingList) 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 *ServiceBindingSecretReference) DeepCopyInto(out *ServiceBindingSecretReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingSecretReference. +func (in *ServiceBindingSecretReference) DeepCopy() *ServiceBindingSecretReference { + if in == nil { + return nil + } + out := new(ServiceBindingSecretReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceBindingServiceReference) DeepCopyInto(out *ServiceBindingServiceReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingServiceReference. +func (in *ServiceBindingServiceReference) DeepCopy() *ServiceBindingServiceReference { + if in == nil { + return nil + } + out := new(ServiceBindingServiceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceBindingSpec) DeepCopyInto(out *ServiceBindingSpec) { + *out = *in + in.Workload.DeepCopyInto(&out.Workload) + out.Service = in.Service + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvMapping, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingSpec. +func (in *ServiceBindingSpec) DeepCopy() *ServiceBindingSpec { + if in == nil { + return nil + } + out := new(ServiceBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceBindingStatus) DeepCopyInto(out *ServiceBindingStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Binding != nil { + in, out := &in.Binding, &out.Binding + *out = new(ServiceBindingSecretReference) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingStatus. +func (in *ServiceBindingStatus) DeepCopy() *ServiceBindingStatus { + if in == nil { + return nil + } + out := new(ServiceBindingStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceBindingWorkloadReference) DeepCopyInto(out *ServiceBindingWorkloadReference) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.Containers != nil { + in, out := &in.Containers, &out.Containers + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingWorkloadReference. +func (in *ServiceBindingWorkloadReference) DeepCopy() *ServiceBindingWorkloadReference { + if in == nil { + return nil + } + out := new(ServiceBindingWorkloadReference) + in.DeepCopyInto(out) + return out +} diff --git a/apis/v1alpha3/clusterworkloadresourcemapping_conversion.go b/apis/v1alpha3/clusterworkloadresourcemapping_conversion.go index 908ef0b4..ce9e3296 100644 --- a/apis/v1alpha3/clusterworkloadresourcemapping_conversion.go +++ b/apis/v1alpha3/clusterworkloadresourcemapping_conversion.go @@ -19,13 +19,13 @@ package v1alpha3 import ( "sigs.k8s.io/controller-runtime/pkg/conversion" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) var _ conversion.Convertible = (*ClusterWorkloadResourceMapping)(nil) func (src *ClusterWorkloadResourceMapping) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*servicebindingv1beta1.ClusterWorkloadResourceMapping) + dst := dstRaw.(*servicebindingv1.ClusterWorkloadResourceMapping) dst.ObjectMeta = src.ObjectMeta dst.Spec = src.Spec @@ -34,7 +34,7 @@ func (src *ClusterWorkloadResourceMapping) ConvertTo(dstRaw conversion.Hub) erro } func (dst *ClusterWorkloadResourceMapping) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*servicebindingv1beta1.ClusterWorkloadResourceMapping) + src := srcRaw.(*servicebindingv1.ClusterWorkloadResourceMapping) dst.ObjectMeta = src.ObjectMeta dst.Spec = src.Spec diff --git a/apis/v1alpha3/clusterworkloadresourcemapping_types.go b/apis/v1alpha3/clusterworkloadresourcemapping_types.go index 82d74d8e..2f868433 100644 --- a/apis/v1alpha3/clusterworkloadresourcemapping_types.go +++ b/apis/v1alpha3/clusterworkloadresourcemapping_types.go @@ -19,12 +19,12 @@ package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // ClusterWorkloadResourceMappingTemplate defines the mapping for a specific version of an workload resource to a // logical PodTemplateSpec-like structure. -type ClusterWorkloadResourceMappingTemplate = servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate +type ClusterWorkloadResourceMappingTemplate = servicebindingv1.ClusterWorkloadResourceMappingTemplate // ClusterWorkloadResourceMappingContainer defines the mapping for a specific fragment of an workload resource // to a Container-like structure. @@ -32,12 +32,12 @@ type ClusterWorkloadResourceMappingTemplate = servicebindingv1beta1.ClusterWorkl // Each mapping defines exactly one path that may match multiple container-like fragments within the workload // resource. For each object matching the path the name, env and volumeMounts expressions are resolved to find those // structures. -type ClusterWorkloadResourceMappingContainer = servicebindingv1beta1.ClusterWorkloadResourceMappingContainer +type ClusterWorkloadResourceMappingContainer = servicebindingv1.ClusterWorkloadResourceMappingContainer // ClusterWorkloadResourceMappingSpec defines the desired state of ClusterWorkloadResourceMapping -type ClusterWorkloadResourceMappingSpec = servicebindingv1beta1.ClusterWorkloadResourceMappingSpec +type ClusterWorkloadResourceMappingSpec = servicebindingv1.ClusterWorkloadResourceMappingSpec -// +kubebuilder:deprecatedversion:warning="servicebinding.io/v1alpha3 is deprecated and will be removed in a future release, use v1beta1 instead" +// +kubebuilder:deprecatedversion:warning="servicebinding.io/v1alpha3 is deprecated and will be removed in a future release, use v1 instead" // +kubebuilder:object:root=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` diff --git a/apis/v1alpha3/clusterworkloadresourcemapping_webhook.go b/apis/v1alpha3/clusterworkloadresourcemapping_webhook.go index 37cbaeb4..bbed3746 100644 --- a/apis/v1alpha3/clusterworkloadresourcemapping_webhook.go +++ b/apis/v1alpha3/clusterworkloadresourcemapping_webhook.go @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func (r *ClusterWorkloadResourceMapping) SetupWebhookWithManager(mgr ctrl.Manager) error { @@ -35,7 +35,7 @@ var _ webhook.Defaulter = &ClusterWorkloadResourceMapping{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) Default() { - r1 := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} r.ConvertTo(r1) r1.Default() r.ConvertFrom(r1) @@ -47,7 +47,7 @@ var _ webhook.Validator = &ClusterWorkloadResourceMapping{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateCreate() (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} if err := r.ConvertTo(r1); err != nil { return nil, err } @@ -56,7 +56,7 @@ func (r *ClusterWorkloadResourceMapping) ValidateCreate() (admission.Warnings, e // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} if err := r.ConvertTo(r1); err != nil { return nil, err } @@ -65,7 +65,7 @@ func (r *ClusterWorkloadResourceMapping) ValidateUpdate(old runtime.Object) (adm // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateDelete() (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} if err := r.ConvertTo(r1); err != nil { return nil, err } diff --git a/apis/v1alpha3/servicebinding_conversion.go b/apis/v1alpha3/servicebinding_conversion.go index 57d61073..9ce57f50 100644 --- a/apis/v1alpha3/servicebinding_conversion.go +++ b/apis/v1alpha3/servicebinding_conversion.go @@ -19,13 +19,13 @@ package v1alpha3 import ( "sigs.k8s.io/controller-runtime/pkg/conversion" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) var _ conversion.Convertible = (*ServiceBinding)(nil) func (src *ServiceBinding) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*servicebindingv1beta1.ServiceBinding) + dst := dstRaw.(*servicebindingv1.ServiceBinding) dst.ObjectMeta = src.ObjectMeta dst.Spec = src.Spec @@ -35,7 +35,7 @@ func (src *ServiceBinding) ConvertTo(dstRaw conversion.Hub) error { } func (dst *ServiceBinding) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*servicebindingv1beta1.ServiceBinding) + src := srcRaw.(*servicebindingv1.ServiceBinding) dst.ObjectMeta = src.ObjectMeta dst.Spec = src.Spec diff --git a/apis/v1alpha3/servicebinding_types.go b/apis/v1alpha3/servicebinding_types.go index 6681f27b..f60b3da3 100644 --- a/apis/v1alpha3/servicebinding_types.go +++ b/apis/v1alpha3/servicebinding_types.go @@ -19,36 +19,36 @@ package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // ServiceBindingWorkloadReference defines a subset of corev1.ObjectReference with extensions -type ServiceBindingWorkloadReference = servicebindingv1beta1.ServiceBindingWorkloadReference +type ServiceBindingWorkloadReference = servicebindingv1.ServiceBindingWorkloadReference // ServiceBindingServiceReference defines a subset of corev1.ObjectReference -type ServiceBindingServiceReference = servicebindingv1beta1.ServiceBindingServiceReference +type ServiceBindingServiceReference = servicebindingv1.ServiceBindingServiceReference // ServiceBindingSecretReference defines a mirror of corev1.LocalObjectReference -type ServiceBindingSecretReference = servicebindingv1beta1.ServiceBindingSecretReference +type ServiceBindingSecretReference = servicebindingv1.ServiceBindingSecretReference // EnvMapping defines a mapping from the value of a Secret entry to an environment variable -type EnvMapping = servicebindingv1beta1.EnvMapping +type EnvMapping = servicebindingv1.EnvMapping // ServiceBindingSpec defines the desired state of ServiceBinding -type ServiceBindingSpec = servicebindingv1beta1.ServiceBindingSpec +type ServiceBindingSpec = servicebindingv1.ServiceBindingSpec // These are valid conditions of ServiceBinding. const ( // ServiceBindingReady means the ServiceBinding has projected the ProvisionedService // secret and the Workload is ready to start. It does not indicate the condition // of either the Service or the Workload resources referenced. - ServiceBindingConditionReady = servicebindingv1beta1.ServiceBindingConditionReady + ServiceBindingConditionReady = servicebindingv1.ServiceBindingConditionReady ) // ServiceBindingStatus defines the observed state of ServiceBinding -type ServiceBindingStatus = servicebindingv1beta1.ServiceBindingStatus +type ServiceBindingStatus = servicebindingv1.ServiceBindingStatus -// +kubebuilder:deprecatedversion:warning="servicebinding.io/v1alpha3 is deprecated and will be removed in a future release, use v1beta1 instead" +// +kubebuilder:deprecatedversion:warning="servicebinding.io/v1alpha3 is deprecated and will be removed in a future release, use v1 instead" // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Secret",type=string,JSONPath=`.status.binding.name` diff --git a/apis/v1alpha3/servicebinding_webhook.go b/apis/v1alpha3/servicebinding_webhook.go index cf9e2336..82bfc7b2 100644 --- a/apis/v1alpha3/servicebinding_webhook.go +++ b/apis/v1alpha3/servicebinding_webhook.go @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func (r *ServiceBinding) SetupWebhookWithManager(mgr ctrl.Manager) error { @@ -35,7 +35,7 @@ var _ webhook.Defaulter = &ServiceBinding{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *ServiceBinding) Default() { - r1 := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} r.ConvertTo(r1) r1.Default() r.ConvertFrom(r1) @@ -47,7 +47,7 @@ var _ webhook.Validator = &ServiceBinding{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateCreate() (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ServiceBinding{} + r1 := &servicebindingv1.ServiceBinding{} if err := r.ConvertTo(r1); err != nil { return nil, err } @@ -56,7 +56,7 @@ func (r *ServiceBinding) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ServiceBinding{} + r1 := &servicebindingv1.ServiceBinding{} if err := r.ConvertTo(r1); err != nil { return nil, err } @@ -65,7 +65,7 @@ func (r *ServiceBinding) ValidateUpdate(old runtime.Object) (admission.Warnings, // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateDelete() (admission.Warnings, error) { - r1 := &servicebindingv1beta1.ServiceBinding{} + r1 := &servicebindingv1.ServiceBinding{} if err := r.ConvertTo(r1); err != nil { return nil, err } diff --git a/apis/v1beta1/clusterworkloadresourcemapping_conversion.go b/apis/v1beta1/clusterworkloadresourcemapping_conversion.go index 92378a38..b6e2c16b 100644 --- a/apis/v1beta1/clusterworkloadresourcemapping_conversion.go +++ b/apis/v1beta1/clusterworkloadresourcemapping_conversion.go @@ -1,5 +1,5 @@ /* - * Copyright 2023 Original Authors + * Copyright 2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,28 @@ package v1beta1 -import "sigs.k8s.io/controller-runtime/pkg/conversion" +import ( + "sigs.k8s.io/controller-runtime/pkg/conversion" -var _ conversion.Hub = (*ClusterWorkloadResourceMapping)(nil) + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" +) -// Hub for conversion -func (r *ClusterWorkloadResourceMapping) Hub() {} +var _ conversion.Convertible = (*ClusterWorkloadResourceMapping)(nil) + +func (src *ClusterWorkloadResourceMapping) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*servicebindingv1.ClusterWorkloadResourceMapping) + + dst.ObjectMeta = src.ObjectMeta + dst.Spec = src.Spec + + return nil +} + +func (dst *ClusterWorkloadResourceMapping) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*servicebindingv1.ClusterWorkloadResourceMapping) + + dst.ObjectMeta = src.ObjectMeta + dst.Spec = src.Spec + + return nil +} diff --git a/apis/v1beta1/clusterworkloadresourcemapping_types.go b/apis/v1beta1/clusterworkloadresourcemapping_types.go index 093cf079..24f9c28f 100644 --- a/apis/v1beta1/clusterworkloadresourcemapping_types.go +++ b/apis/v1beta1/clusterworkloadresourcemapping_types.go @@ -1,5 +1,5 @@ /* - * Copyright 2021 Original Authors + * Copyright 2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,24 +16,15 @@ package v1beta1 -import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" +) // ClusterWorkloadResourceMappingTemplate defines the mapping for a specific version of an workload resource to a // logical PodTemplateSpec-like structure. -type ClusterWorkloadResourceMappingTemplate struct { - // Version is the version of the workload resource that this mapping is for. - Version string `json:"version"` - // Annotations is a Restricted JSONPath that references the annotations map within the workload resource. These - // annotations must end up in the resulting Pod, and are generally not the workload resource's annotations. - // Defaults to `.spec.template.metadata.annotations`. - Annotations string `json:"annotations,omitempty"` - // Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to - // mappings appropriate for a PodSpecable resource. - Containers []ClusterWorkloadResourceMappingContainer `json:"containers,omitempty"` - // Volumes is a Restricted JSONPath that references the slice of volumes within the workload resource. Defaults to - // `.spec.template.spec.volumes`. - Volumes string `json:"volumes,omitempty"` -} +type ClusterWorkloadResourceMappingTemplate = servicebindingv1.ClusterWorkloadResourceMappingTemplate // ClusterWorkloadResourceMappingContainer defines the mapping for a specific fragment of an workload resource // to a Container-like structure. @@ -41,31 +32,13 @@ type ClusterWorkloadResourceMappingTemplate struct { // Each mapping defines exactly one path that may match multiple container-like fragments within the workload // resource. For each object matching the path the name, env and volumeMounts expressions are resolved to find those // structures. -type ClusterWorkloadResourceMappingContainer struct { - // Path is the JSONPath within the workload resource that matches an existing fragment that is container-like. - Path string `json:"path"` - // Name is a Restricted JSONPath that references the name of the container with the container-like workload resource - // fragment. If not defined, container name filtering is ignored. - Name string `json:"name,omitempty"` - // Env is a Restricted JSONPath that references the slice of environment variables for the container with the - // container-like workload resource fragment. The referenced location is created if it does not exist. Defaults - // to `.envs`. - Env string `json:"env,omitempty"` - // VolumeMounts is a Restricted JSONPath that references the slice of volume mounts for the container with the - // container-like workload resource fragment. The referenced location is created if it does not exist. Defaults - // to `.volumeMounts`. - VolumeMounts string `json:"volumeMounts,omitempty"` -} +type ClusterWorkloadResourceMappingContainer = servicebindingv1.ClusterWorkloadResourceMappingContainer // ClusterWorkloadResourceMappingSpec defines the desired state of ClusterWorkloadResourceMapping -type ClusterWorkloadResourceMappingSpec struct { - // Versions is the collection of versions for a given resource, with mappings. - Versions []ClusterWorkloadResourceMappingTemplate `json:"versions,omitempty"` -} +type ClusterWorkloadResourceMappingSpec = servicebindingv1.ClusterWorkloadResourceMappingSpec // +kubebuilder:object:root=true // +kubebuilder:resource:scope=Cluster -// +kubebuilder:storageversion // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // ClusterWorkloadResourceMapping is the Schema for the clusterworkloadresourcemappings API diff --git a/apis/v1beta1/clusterworkloadresourcemapping_webhook.go b/apis/v1beta1/clusterworkloadresourcemapping_webhook.go index 9ea2b969..6ffc5895 100644 --- a/apis/v1beta1/clusterworkloadresourcemapping_webhook.go +++ b/apis/v1beta1/clusterworkloadresourcemapping_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2021 the original author or authors. +Copyright 2023 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,14 +17,12 @@ limitations under the License. package v1beta1 import ( - "fmt" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/client-go/util/jsonpath" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func (r *ClusterWorkloadResourceMapping) SetupWebhookWithManager(mgr ctrl.Manager) error { @@ -37,40 +35,10 @@ var _ webhook.Defaulter = &ClusterWorkloadResourceMapping{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) Default() { - for i := range r.Spec.Versions { - r.Spec.Versions[i].Default() - } -} - -// Default applies values that are appropriate for a PodSpecable resource -func (r *ClusterWorkloadResourceMappingTemplate) Default() { - if r.Annotations == "" { - r.Annotations = ".spec.template.metadata.annotations" - } - if len(r.Containers) == 0 { - r.Containers = []ClusterWorkloadResourceMappingContainer{ - { - Path: ".spec.template.spec.initContainers[*]", - Name: ".name", - }, - { - Path: ".spec.template.spec.containers[*]", - Name: ".name", - }, - } - } - for i := range r.Containers { - c := &r.Containers[i] - if c.Env == "" { - c.Env = ".env" - } - if c.VolumeMounts == "" { - c.VolumeMounts = ".volumeMounts" - } - } - if r.Volumes == "" { - r.Volumes = ".spec.template.spec.volumes" - } + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} + r.ConvertTo(r1) + r1.Default() + r.ConvertFrom(r1) } //+kubebuilder:webhook:path=/validate-servicebinding-io-v1beta1-clusterworkloadresourcemapping,mutating=false,failurePolicy=fail,sideEffects=None,groups=servicebinding.io,resources=clusterworkloadresourcemappings,verbs=create;update,versions=v1beta1,name=v1beta1.clusterworkloadresourcemappings.servicebinding.io,admissionReviewVersions={v1,v1beta1} @@ -79,103 +47,27 @@ var _ webhook.Validator = &ClusterWorkloadResourceMapping{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateCreate() (admission.Warnings, error) { - r.Default() - return nil, r.validate().ToAggregate() + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} + if err := r.ConvertTo(r1); err != nil { + return nil, err + } + return r1.ValidateCreate() } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - r.Default() - // TODO(user): check for immutable fields, if any - return nil, r.validate().ToAggregate() + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} + if err := r.ConvertTo(r1); err != nil { + return nil, err + } + return r1.ValidateUpdate(old) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *ClusterWorkloadResourceMapping) ValidateDelete() (admission.Warnings, error) { - return nil, nil -} - -func (r *ClusterWorkloadResourceMapping) validate() field.ErrorList { - errs := field.ErrorList{} - - versions := map[string]int{} - for i := range r.Spec.Versions { - // check for duplicate versions - if p, ok := versions[r.Spec.Versions[i].Version]; ok { - errs = append(errs, field.Duplicate(field.NewPath("spec", "versions", fmt.Sprintf("[%d, %d]", p, i), "version"), r.Spec.Versions[i].Version)) - } - versions[r.Spec.Versions[i].Version] = i - errs = append(errs, r.Spec.Versions[i].validate(field.NewPath("spec", "versions").Index(i))...) - } - - return errs -} - -func (r *ClusterWorkloadResourceMappingTemplate) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if r.Version == "" { - errs = append(errs, field.Required(fldPath.Child("version"), "")) - } - errs = append(errs, validateRestrictedJsonPath(r.Annotations, fldPath.Child("annotations"))...) - errs = append(errs, validateRestrictedJsonPath(r.Volumes, fldPath.Child("volumes"))...) - for i := range r.Containers { - errs = append(errs, r.Containers[i].validate(fldPath.Child("containers").Index(i))...) - } - - return errs -} - -func (r *ClusterWorkloadResourceMappingContainer) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - errs = append(errs, validateJsonPath(r.Path, fldPath.Child("path"))...) - if r.Name != "" { - // name is optional - errs = append(errs, validateRestrictedJsonPath(r.Name, fldPath.Child("name"))...) - } - errs = append(errs, validateRestrictedJsonPath(r.Env, fldPath.Child("env"))...) - errs = append(errs, validateRestrictedJsonPath(r.VolumeMounts, fldPath.Child("volumeMounts"))...) - - return errs -} - -func validateJsonPath(expression string, fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if p, err := jsonpath.Parse("", fmt.Sprintf("{%s}", expression)); err != nil { - errs = append(errs, field.Invalid(fldPath, expression, err.Error())) - } else { - if len(p.Root.Nodes) != 1 { - errs = append(errs, field.Invalid(fldPath, expression, "too many root nodes")) - } + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} + if err := r.ConvertTo(r1); err != nil { + return nil, err } - - return errs -} - -func validateRestrictedJsonPath(expression string, fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if p, err := jsonpath.Parse("", fmt.Sprintf("{%s}", expression)); err != nil { - errs = append(errs, field.Invalid(fldPath, expression, err.Error())) - } else { - if len(p.Root.Nodes) != 1 { - errs = append(errs, field.Invalid(fldPath, expression, "too many root nodes")) - } - // only allow jsonpath.NodeField nodes - nodes := p.Root.Nodes - for i := 0; i < len(nodes); i++ { - switch n := nodes[i].(type) { - case *jsonpath.ListNode: - nodes = append(nodes, n.Nodes...) - case *jsonpath.FieldNode: - continue - default: - errs = append(errs, field.Invalid(fldPath, expression, fmt.Sprintf("unsupported node: %s", n))) - } - } - } - - return errs + return r1.ValidateDelete() } diff --git a/apis/v1beta1/groupversion_info.go b/apis/v1beta1/groupversion_info.go index 268d49ec..614c0170 100644 --- a/apis/v1beta1/groupversion_info.go +++ b/apis/v1beta1/groupversion_info.go @@ -1,5 +1,5 @@ /* -Copyright 2022 the original author or authors. +Copyright 2021 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 contains API Schema definitions for the servicebinding.io v1beta1 API group -// +kubebuilder:object:generate=true +// Package v1beta1 contains API Schema definitions for the v1beta1 API group +// +kubebuilder:object:generate=false // +groupName=servicebinding.io package v1beta1 diff --git a/apis/v1beta1/servicebinding_conversion.go b/apis/v1beta1/servicebinding_conversion.go index 527c640e..4004833d 100644 --- a/apis/v1beta1/servicebinding_conversion.go +++ b/apis/v1beta1/servicebinding_conversion.go @@ -1,5 +1,5 @@ /* - * Copyright 2023 Original Authors + * Copyright 2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,28 @@ package v1beta1 import ( "sigs.k8s.io/controller-runtime/pkg/conversion" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) -var _ conversion.Hub = (*ServiceBinding)(nil) +var _ conversion.Convertible = (*ServiceBinding)(nil) + +func (src *ServiceBinding) ConvertTo(dstRaw conversion.Hub) error { + dst := dstRaw.(*servicebindingv1.ServiceBinding) + + dst.ObjectMeta = src.ObjectMeta + dst.Spec = src.Spec + dst.Status = src.Status + + return nil +} + +func (dst *ServiceBinding) ConvertFrom(srcRaw conversion.Hub) error { + src := srcRaw.(*servicebindingv1.ServiceBinding) + + dst.ObjectMeta = src.ObjectMeta + dst.Spec = src.Spec + dst.Status = src.Status -// Hub for conversion -func (r *ServiceBinding) Hub() {} + return nil +} diff --git a/apis/v1beta1/servicebinding_types.go b/apis/v1beta1/servicebinding_types.go index 52da9b0c..d6b0dc79 100644 --- a/apis/v1beta1/servicebinding_types.go +++ b/apis/v1beta1/servicebinding_types.go @@ -1,5 +1,5 @@ /* - * Copyright 2020 Original Authors + * Copyright 2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,82 +18,47 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // ServiceBindingWorkloadReference defines a subset of corev1.ObjectReference with extensions -type ServiceBindingWorkloadReference struct { - // API version of the referent. - APIVersion string `json:"apiVersion"` - // Kind of the referent. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - Kind string `json:"kind"` - // Name of the referent. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - Name string `json:"name,omitempty"` - // Selector is a query that selects the workload or workloads to bind the service to - Selector *metav1.LabelSelector `json:"selector,omitempty"` - // Containers describes which containers in a Pod should be bound to - Containers []string `json:"containers,omitempty"` -} +type ServiceBindingWorkloadReference = servicebindingv1.ServiceBindingWorkloadReference // ServiceBindingServiceReference defines a subset of corev1.ObjectReference -type ServiceBindingServiceReference struct { - // API version of the referent. - APIVersion string `json:"apiVersion"` - // Kind of the referent. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - Kind string `json:"kind"` - // Name of the referent. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - Name string `json:"name"` -} +type ServiceBindingServiceReference = servicebindingv1.ServiceBindingServiceReference // ServiceBindingSecretReference defines a mirror of corev1.LocalObjectReference -type ServiceBindingSecretReference struct { - // Name of the referent secret. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - Name string `json:"name"` -} +type ServiceBindingSecretReference = servicebindingv1.ServiceBindingSecretReference // EnvMapping defines a mapping from the value of a Secret entry to an environment variable -type EnvMapping struct { - // Name is the name of the environment variable - Name string `json:"name"` - // Key is the key in the Secret that will be exposed - Key string `json:"key"` -} +type EnvMapping = servicebindingv1.EnvMapping // ServiceBindingSpec defines the desired state of ServiceBinding -type ServiceBindingSpec struct { - // Name is the name of the service as projected into the workload container. Defaults to .metadata.name. - Name string `json:"name,omitempty"` - // Type is the type of the service as projected into the workload container - Type string `json:"type,omitempty"` - // Provider is the provider of the service as projected into the workload container - Provider string `json:"provider,omitempty"` - // Workload is a reference to an object - Workload ServiceBindingWorkloadReference `json:"workload"` - // Service is a reference to an object that fulfills the ProvisionedService duck type - Service ServiceBindingServiceReference `json:"service"` - // Env is the collection of mappings from Secret entries to environment variables - Env []EnvMapping `json:"env,omitempty"` -} +type ServiceBindingSpec = servicebindingv1.ServiceBindingSpec + +// These are valid conditions of ServiceBinding. +const ( + // ServiceBindingReady means the ServiceBinding has projected the ProvisionedService + // secret and the Workload is ready to start. It does not indicate the condition + // of either the Service or the Workload resources referenced. + ServiceBindingConditionReady = servicebindingv1.ServiceBindingConditionReady + // ServiceBindingConditionServiceAvailable means the ServiceBinding's service + // reference resolved to a ProvisionedService and found a secret. It does not + // indicate the condition of the Service. + ServiceBindingConditionServiceAvailable = servicebindingv1.ServiceBindingConditionServiceAvailable + // ServiceBindingConditionWorkloadProjected means the ServiceBinding has projected + // the ProvisionedService secret and the Workload is ready to start. It does not + // indicate the condition of the Workload resources referenced. + // + // Not a standardized condition. + ServiceBindingConditionWorkloadProjected = servicebindingv1.ServiceBindingConditionWorkloadProjected +) // ServiceBindingStatus defines the observed state of ServiceBinding -type ServiceBindingStatus struct { - // ObservedGeneration is the 'Generation' of the ServiceBinding that - // was last processed by the controller. - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - - // Conditions are the conditions of this ServiceBinding - Conditions []metav1.Condition `json:"conditions,omitempty"` - - // Binding exposes the projected secret for this ServiceBinding - Binding *ServiceBindingSecretReference `json:"binding,omitempty"` -} +type ServiceBindingStatus = servicebindingv1.ServiceBindingStatus // +kubebuilder:object:root=true -// +kubebuilder:storageversion // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Secret",type=string,JSONPath=`.status.binding.name` // +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` diff --git a/apis/v1beta1/servicebinding_webhook.go b/apis/v1beta1/servicebinding_webhook.go index e67d0289..7eae6624 100644 --- a/apis/v1beta1/servicebinding_webhook.go +++ b/apis/v1beta1/servicebinding_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2021 the original author or authors. +Copyright 2023 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,15 +17,12 @@ limitations under the License. package v1beta1 import ( - "fmt" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func (r *ServiceBinding) SetupWebhookWithManager(mgr ctrl.Manager) error { @@ -38,9 +35,10 @@ var _ webhook.Defaulter = &ServiceBinding{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *ServiceBinding) Default() { - if r.Spec.Name == "" { - r.Spec.Name = r.Name - } + r1 := &servicebindingv1.ClusterWorkloadResourceMapping{} + r.ConvertTo(r1) + r1.Default() + r.ConvertFrom(r1) } //+kubebuilder:webhook:path=/validate-servicebinding-io-v1beta1-servicebinding,mutating=false,failurePolicy=fail,sideEffects=None,groups=servicebinding.io,resources=servicebindings,verbs=create;update,versions=v1beta1,name=v1beta1.servicebindings.servicebinding.io,admissionReviewVersions={v1,v1beta1} @@ -49,126 +47,27 @@ var _ webhook.Validator = &ServiceBinding{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateCreate() (admission.Warnings, error) { - r.Default() - return nil, r.validate().ToAggregate() + r1 := &servicebindingv1.ServiceBinding{} + if err := r.ConvertTo(r1); err != nil { + return nil, err + } + return r1.ValidateCreate() } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - r.Default() - - errs := field.ErrorList{} - - // check immutable fields - var ro *ServiceBinding - if o, ok := old.(*ServiceBinding); ok { - ro = o - } else if o, ok := old.(conversion.Convertible); ok { - ro = &ServiceBinding{} - if err := o.ConvertTo(ro); err != nil { - return nil, err - } - } else { - errs = append(errs, - field.InternalError(nil, fmt.Errorf("old object must be of type v1beta1.ServiceBinding")), - ) - } - if len(errs) == 0 { - if r.Spec.Workload.APIVersion != ro.Spec.Workload.APIVersion { - errs = append(errs, - field.Forbidden(field.NewPath("spec", "workload", "apiVersion"), "Workload apiVersion is immutable. Delete and recreate the ServiceBinding to update."), - ) - } - if r.Spec.Workload.Kind != ro.Spec.Workload.Kind { - errs = append(errs, - field.Forbidden(field.NewPath("spec", "workload", "kind"), "Workload kind is immutable. Delete and recreate the ServiceBinding to update."), - ) - } + r1 := &servicebindingv1.ServiceBinding{} + if err := r.ConvertTo(r1); err != nil { + return nil, err } - - // validate new object - errs = append(errs, r.validate()...) - - return nil, errs.ToAggregate() + return r1.ValidateUpdate(old) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *ServiceBinding) ValidateDelete() (admission.Warnings, error) { - return nil, nil -} - -func (r *ServiceBinding) validate() field.ErrorList { - errs := field.ErrorList{} - - errs = append(errs, r.Spec.validate(field.NewPath("spec"))...) - - return errs -} - -func (r *ServiceBindingSpec) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if r.Name == "" { - errs = append(errs, field.Required(fldPath.Child("name"), "")) - } - errs = append(errs, r.Service.validate(fldPath.Child("service"))...) - errs = append(errs, r.Workload.validate(fldPath.Child("workload"))...) - for i := range r.Env { - errs = append(errs, r.Env[i].validate(fldPath.Child("env").Index(i))...) - } - - return errs -} - -func (r *ServiceBindingServiceReference) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if r.APIVersion == "" { - errs = append(errs, field.Required(fldPath.Child("apiVersion"), "")) - } - if r.Kind == "" { - errs = append(errs, field.Required(fldPath.Child("kind"), "")) - } - if r.Name == "" { - errs = append(errs, field.Required(fldPath.Child("name"), "")) - } - - return errs -} - -func (r *ServiceBindingWorkloadReference) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if r.APIVersion == "" { - errs = append(errs, field.Required(fldPath.Child("apiVersion"), "")) - } - if r.Kind == "" { - errs = append(errs, field.Required(fldPath.Child("kind"), "")) + r1 := &servicebindingv1.ServiceBinding{} + if err := r.ConvertTo(r1); err != nil { + return nil, err } - if r.Name == "" && r.Selector == nil { - errs = append(errs, field.Required(fldPath.Child("[name, selector]"), "expected exactly one, got neither")) - } - if r.Name != "" && r.Selector != nil { - errs = append(errs, field.Required(fldPath.Child("[name, selector]"), "expected exactly one, got both")) - } - if r.Selector != nil { - if _, err := metav1.LabelSelectorAsSelector(r.Selector); err != nil { - errs = append(errs, field.Invalid(fldPath.Child("selector"), r.Selector, err.Error())) - } - } - - return errs -} - -func (r *EnvMapping) validate(fldPath *field.Path) field.ErrorList { - errs := field.ErrorList{} - - if r.Name == "" { - errs = append(errs, field.Required(fldPath.Child("name"), "")) - } - if r.Key == "" { - errs = append(errs, field.Required(fldPath.Child("key"), "")) - } - - return errs + return r1.ValidateDelete() } diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index 5d4da048..f43f6366 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -21,7 +21,6 @@ limitations under the License. package v1beta1 import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -51,21 +50,6 @@ func (in *ClusterWorkloadResourceMapping) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterWorkloadResourceMappingContainer) DeepCopyInto(out *ClusterWorkloadResourceMappingContainer) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingContainer. -func (in *ClusterWorkloadResourceMappingContainer) DeepCopy() *ClusterWorkloadResourceMappingContainer { - if in == nil { - return nil - } - out := new(ClusterWorkloadResourceMappingContainer) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterWorkloadResourceMappingList) DeepCopyInto(out *ClusterWorkloadResourceMappingList) { *out = *in @@ -98,63 +82,6 @@ func (in *ClusterWorkloadResourceMappingList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterWorkloadResourceMappingSpec) DeepCopyInto(out *ClusterWorkloadResourceMappingSpec) { - *out = *in - if in.Versions != nil { - in, out := &in.Versions, &out.Versions - *out = make([]ClusterWorkloadResourceMappingTemplate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingSpec. -func (in *ClusterWorkloadResourceMappingSpec) DeepCopy() *ClusterWorkloadResourceMappingSpec { - if in == nil { - return nil - } - out := new(ClusterWorkloadResourceMappingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterWorkloadResourceMappingTemplate) DeepCopyInto(out *ClusterWorkloadResourceMappingTemplate) { - *out = *in - if in.Containers != nil { - in, out := &in.Containers, &out.Containers - *out = make([]ClusterWorkloadResourceMappingContainer, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterWorkloadResourceMappingTemplate. -func (in *ClusterWorkloadResourceMappingTemplate) DeepCopy() *ClusterWorkloadResourceMappingTemplate { - if in == nil { - return nil - } - out := new(ClusterWorkloadResourceMappingTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvMapping) DeepCopyInto(out *EnvMapping) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvMapping. -func (in *EnvMapping) DeepCopy() *EnvMapping { - if in == nil { - return nil - } - out := new(EnvMapping) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceBinding) DeepCopyInto(out *ServiceBinding) { *out = *in @@ -213,107 +140,3 @@ func (in *ServiceBindingList) DeepCopyObject() runtime.Object { } return nil } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceBindingSecretReference) DeepCopyInto(out *ServiceBindingSecretReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingSecretReference. -func (in *ServiceBindingSecretReference) DeepCopy() *ServiceBindingSecretReference { - if in == nil { - return nil - } - out := new(ServiceBindingSecretReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceBindingServiceReference) DeepCopyInto(out *ServiceBindingServiceReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingServiceReference. -func (in *ServiceBindingServiceReference) DeepCopy() *ServiceBindingServiceReference { - if in == nil { - return nil - } - out := new(ServiceBindingServiceReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceBindingSpec) DeepCopyInto(out *ServiceBindingSpec) { - *out = *in - in.Workload.DeepCopyInto(&out.Workload) - out.Service = in.Service - if in.Env != nil { - in, out := &in.Env, &out.Env - *out = make([]EnvMapping, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingSpec. -func (in *ServiceBindingSpec) DeepCopy() *ServiceBindingSpec { - if in == nil { - return nil - } - out := new(ServiceBindingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceBindingStatus) DeepCopyInto(out *ServiceBindingStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Binding != nil { - in, out := &in.Binding, &out.Binding - *out = new(ServiceBindingSecretReference) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingStatus. -func (in *ServiceBindingStatus) DeepCopy() *ServiceBindingStatus { - if in == nil { - return nil - } - out := new(ServiceBindingStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceBindingWorkloadReference) DeepCopyInto(out *ServiceBindingWorkloadReference) { - *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.Containers != nil { - in, out := &in.Containers, &out.Containers - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceBindingWorkloadReference. -func (in *ServiceBindingWorkloadReference) DeepCopy() *ServiceBindingWorkloadReference { - if in == nil { - return nil - } - out := new(ServiceBindingWorkloadReference) - in.DeepCopyInto(out) - return out -} diff --git a/config/crd/bases/servicebinding.io_clusterworkloadresourcemappings.yaml b/config/crd/bases/servicebinding.io_clusterworkloadresourcemappings.yaml index f4c2a241..1083a57d 100644 --- a/config/crd/bases/servicebinding.io_clusterworkloadresourcemappings.yaml +++ b/config/crd/bases/servicebinding.io_clusterworkloadresourcemappings.yaml @@ -14,13 +14,115 @@ spec: singular: clusterworkloadresourcemapping scope: Cluster versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: ClusterWorkloadResourceMapping is the Schema for the clusterworkloadresourcemappings + API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: ClusterWorkloadResourceMappingSpec defines the desired state + of ClusterWorkloadResourceMapping + properties: + versions: + description: Versions is the collection of versions for a given resource, + with mappings. + items: + description: |- + ClusterWorkloadResourceMappingTemplate defines the mapping for a specific version of an workload resource to a + logical PodTemplateSpec-like structure. + properties: + annotations: + description: |- + Annotations is a Restricted JSONPath that references the annotations map within the workload resource. These + annotations must end up in the resulting Pod, and are generally not the workload resource's annotations. + Defaults to `.spec.template.metadata.annotations`. + type: string + containers: + description: |- + Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to + mappings appropriate for a PodSpecable resource. + items: + description: |- + ClusterWorkloadResourceMappingContainer defines the mapping for a specific fragment of an workload resource + to a Container-like structure. + + + Each mapping defines exactly one path that may match multiple container-like fragments within the workload + resource. For each object matching the path the name, env and volumeMounts expressions are resolved to find those + structures. + properties: + env: + description: |- + Env is a Restricted JSONPath that references the slice of environment variables for the container with the + container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + to `.envs`. + type: string + name: + description: |- + Name is a Restricted JSONPath that references the name of the container with the container-like workload resource + fragment. If not defined, container name filtering is ignored. + type: string + path: + description: Path is the JSONPath within the workload + resource that matches an existing fragment that is container-like. + type: string + volumeMounts: + description: |- + VolumeMounts is a Restricted JSONPath that references the slice of volume mounts for the container with the + container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + to `.volumeMounts`. + type: string + required: + - path + type: object + type: array + version: + description: Version is the version of the workload resource + that this mapping is for. + type: string + volumes: + description: |- + Volumes is a Restricted JSONPath that references the slice of volumes within the workload resource. Defaults to + `.spec.template.spec.volumes`. + type: string + required: + - version + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: {} - additionalPrinterColumns: - jsonPath: .metadata.creationTimestamp name: Age type: date deprecated: true deprecationWarning: servicebinding.io/v1alpha3 is deprecated and will be removed - in a future release, use v1beta1 instead + in a future release, use v1 instead name: v1alpha3 schema: openAPIV3Schema: @@ -219,5 +321,5 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: {} diff --git a/config/crd/bases/servicebinding.io_servicebindings.yaml b/config/crd/bases/servicebinding.io_servicebindings.yaml index 02201a88..f13f3625 100644 --- a/config/crd/bases/servicebinding.io_servicebindings.yaml +++ b/config/crd/bases/servicebinding.io_servicebindings.yaml @@ -14,6 +14,267 @@ spec: singular: servicebinding scope: Namespaced versions: + - additionalPrinterColumns: + - jsonPath: .status.binding.name + name: Secret + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].reason + name: Reason + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: ServiceBinding is the Schema for the servicebindings API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: ServiceBindingSpec defines the desired state of ServiceBinding + properties: + env: + description: Env is the collection of mappings from Secret entries + to environment variables + items: + description: EnvMapping defines a mapping from the value of a Secret + entry to an environment variable + properties: + key: + description: Key is the key in the Secret that will be exposed + type: string + name: + description: Name is the name of the environment variable + type: string + required: + - key + - name + type: object + type: array + name: + description: Name is the name of the service as projected into the + workload container. Defaults to .metadata.name. + type: string + provider: + description: Provider is the provider of the service as projected + into the workload container + type: string + service: + description: Service is a reference to an object that fulfills the + ProvisionedService duck type + properties: + apiVersion: + description: API version of the referent. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + required: + - apiVersion + - kind + - name + type: object + type: + description: Type is the type of the service as projected into the + workload container + type: string + workload: + description: Workload is a reference to an object + properties: + apiVersion: + description: API version of the referent. + type: string + containers: + description: Containers describes which containers in a Pod should + be bound to + items: + type: string + type: array + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + selector: + description: Selector is a query that selects the workload or + workloads to bind the service to + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - apiVersion + - kind + type: object + required: + - service + - workload + type: object + status: + description: ServiceBindingStatus defines the observed state of ServiceBinding + properties: + binding: + description: Binding exposes the projected secret for this ServiceBinding + properties: + name: + description: |- + Name of the referent secret. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + required: + - name + type: object + conditions: + description: Conditions are the conditions of this ServiceBinding + items: + description: "Condition contains details for one aspect of the current + state of this API Resource.\n---\nThis struct is intended for + direct use as an array at the field path .status.conditions. For + example,\n\n\n\ttype FooStatus struct{\n\t // Represents the + observations of a foo's current state.\n\t // Known .status.conditions.type + are: \"Available\", \"Progressing\", and \"Degraded\"\n\t // + +patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t + \ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t + \ // other fields\n\t}" + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + --- + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + useful (see .node.status.conditions), the ability to deconflict is important. + The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + observedGeneration: + description: |- + ObservedGeneration is the 'Generation' of the ServiceBinding that + was last processed by the controller. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} - additionalPrinterColumns: - jsonPath: .status.binding.name name: Secret @@ -29,7 +290,7 @@ spec: type: date deprecated: true deprecationWarning: servicebinding.io/v1alpha3 is deprecated and will be removed - in a future release, use v1beta1 instead + in a future release, use v1 instead name: v1alpha3 schema: openAPIV3Schema: @@ -536,6 +797,6 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} diff --git a/config/samples/servicebinding.io_v1beta1_clusterworkloadresourcemapping.yaml b/config/samples/servicebinding.io_v1_clusterworkloadresourcemapping.yaml similarity index 77% rename from config/samples/servicebinding.io_v1beta1_clusterworkloadresourcemapping.yaml rename to config/samples/servicebinding.io_v1_clusterworkloadresourcemapping.yaml index b92bfb11..b3356519 100644 --- a/config/samples/servicebinding.io_v1beta1_clusterworkloadresourcemapping.yaml +++ b/config/samples/servicebinding.io_v1_clusterworkloadresourcemapping.yaml @@ -1,4 +1,4 @@ -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ClusterWorkloadResourceMapping metadata: name: clusterworkloadresourcemapping-sample diff --git a/config/samples/servicebinding.io_v1beta1_servicebinding.yaml b/config/samples/servicebinding.io_v1_servicebinding.yaml similarity index 72% rename from config/samples/servicebinding.io_v1beta1_servicebinding.yaml rename to config/samples/servicebinding.io_v1_servicebinding.yaml index 30eb60e3..6e343e29 100644 --- a/config/samples/servicebinding.io_v1beta1_servicebinding.yaml +++ b/config/samples/servicebinding.io_v1_servicebinding.yaml @@ -1,4 +1,4 @@ -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: servicebinding-sample diff --git a/config/servicebinding-runtime.yaml b/config/servicebinding-runtime.yaml index 920844df..1cf82a63 100644 --- a/config/servicebinding-runtime.yaml +++ b/config/servicebinding-runtime.yaml @@ -33,13 +33,115 @@ spec: singular: clusterworkloadresourcemapping scope: Cluster versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: ClusterWorkloadResourceMapping is the Schema for the clusterworkloadresourcemappings + API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: ClusterWorkloadResourceMappingSpec defines the desired state + of ClusterWorkloadResourceMapping + properties: + versions: + description: Versions is the collection of versions for a given resource, + with mappings. + items: + description: |- + ClusterWorkloadResourceMappingTemplate defines the mapping for a specific version of an workload resource to a + logical PodTemplateSpec-like structure. + properties: + annotations: + description: |- + Annotations is a Restricted JSONPath that references the annotations map within the workload resource. These + annotations must end up in the resulting Pod, and are generally not the workload resource's annotations. + Defaults to `.spec.template.metadata.annotations`. + type: string + containers: + description: |- + Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to + mappings appropriate for a PodSpecable resource. + items: + description: |- + ClusterWorkloadResourceMappingContainer defines the mapping for a specific fragment of an workload resource + to a Container-like structure. + + + Each mapping defines exactly one path that may match multiple container-like fragments within the workload + resource. For each object matching the path the name, env and volumeMounts expressions are resolved to find those + structures. + properties: + env: + description: |- + Env is a Restricted JSONPath that references the slice of environment variables for the container with the + container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + to `.envs`. + type: string + name: + description: |- + Name is a Restricted JSONPath that references the name of the container with the container-like workload resource + fragment. If not defined, container name filtering is ignored. + type: string + path: + description: Path is the JSONPath within the workload + resource that matches an existing fragment that is container-like. + type: string + volumeMounts: + description: |- + VolumeMounts is a Restricted JSONPath that references the slice of volume mounts for the container with the + container-like workload resource fragment. The referenced location is created if it does not exist. Defaults + to `.volumeMounts`. + type: string + required: + - path + type: object + type: array + version: + description: Version is the version of the workload resource + that this mapping is for. + type: string + volumes: + description: |- + Volumes is a Restricted JSONPath that references the slice of volumes within the workload resource. Defaults to + `.spec.template.spec.volumes`. + type: string + required: + - version + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: {} - additionalPrinterColumns: - jsonPath: .metadata.creationTimestamp name: Age type: date deprecated: true deprecationWarning: servicebinding.io/v1alpha3 is deprecated and will be removed - in a future release, use v1beta1 instead + in a future release, use v1 instead name: v1alpha3 schema: openAPIV3Schema: @@ -238,7 +340,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: {} --- apiVersion: apiextensions.k8s.io/v1 @@ -256,6 +358,267 @@ spec: singular: servicebinding scope: Namespaced versions: + - additionalPrinterColumns: + - jsonPath: .status.binding.name + name: Secret + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].reason + name: Reason + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: ServiceBinding is the Schema for the servicebindings API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: ServiceBindingSpec defines the desired state of ServiceBinding + properties: + env: + description: Env is the collection of mappings from Secret entries + to environment variables + items: + description: EnvMapping defines a mapping from the value of a Secret + entry to an environment variable + properties: + key: + description: Key is the key in the Secret that will be exposed + type: string + name: + description: Name is the name of the environment variable + type: string + required: + - key + - name + type: object + type: array + name: + description: Name is the name of the service as projected into the + workload container. Defaults to .metadata.name. + type: string + provider: + description: Provider is the provider of the service as projected + into the workload container + type: string + service: + description: Service is a reference to an object that fulfills the + ProvisionedService duck type + properties: + apiVersion: + description: API version of the referent. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + required: + - apiVersion + - kind + - name + type: object + type: + description: Type is the type of the service as projected into the + workload container + type: string + workload: + description: Workload is a reference to an object + properties: + apiVersion: + description: API version of the referent. + type: string + containers: + description: Containers describes which containers in a Pod should + be bound to + items: + type: string + type: array + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + selector: + description: Selector is a query that selects the workload or + workloads to bind the service to + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - apiVersion + - kind + type: object + required: + - service + - workload + type: object + status: + description: ServiceBindingStatus defines the observed state of ServiceBinding + properties: + binding: + description: Binding exposes the projected secret for this ServiceBinding + properties: + name: + description: |- + Name of the referent secret. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + required: + - name + type: object + conditions: + description: Conditions are the conditions of this ServiceBinding + items: + description: "Condition contains details for one aspect of the current + state of this API Resource.\n---\nThis struct is intended for + direct use as an array at the field path .status.conditions. For + example,\n\n\n\ttype FooStatus struct{\n\t // Represents the + observations of a foo's current state.\n\t // Known .status.conditions.type + are: \"Available\", \"Progressing\", and \"Degraded\"\n\t // + +patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t + \ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t + \ // other fields\n\t}" + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + --- + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + useful (see .node.status.conditions), the ability to deconflict is important. + The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + observedGeneration: + description: |- + ObservedGeneration is the 'Generation' of the ServiceBinding that + was last processed by the controller. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} - additionalPrinterColumns: - jsonPath: .status.binding.name name: Secret @@ -271,7 +634,7 @@ spec: type: date deprecated: true deprecationWarning: servicebinding.io/v1alpha3 is deprecated and will be removed - in a future release, use v1beta1 instead + in a future release, use v1 instead name: v1alpha3 schema: openAPIV3Schema: @@ -778,7 +1141,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} --- @@ -1234,14 +1597,14 @@ webhooks: service: name: servicebinding-webhook-service namespace: servicebinding-system - path: /validate-servicebinding-io-v1beta1-clusterworkloadresourcemapping + path: /validate-servicebinding-io-v1-clusterworkloadresourcemapping failurePolicy: Fail - name: v1beta1.clusterworkloadresourcemappings.servicebinding.io + name: v1.clusterworkloadresourcemappings.servicebinding.io rules: - apiGroups: - servicebinding.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -1255,14 +1618,14 @@ webhooks: service: name: servicebinding-webhook-service namespace: servicebinding-system - path: /validate-servicebinding-io-v1beta1-servicebinding + path: /validate-servicebinding-io-v1-servicebinding failurePolicy: Fail - name: v1beta1.servicebindings.servicebinding.io + name: v1.servicebindings.servicebinding.io rules: - apiGroups: - servicebinding.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -1311,3 +1674,45 @@ webhooks: resources: - servicebindings sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta1 + clientConfig: + service: + name: servicebinding-webhook-service + namespace: servicebinding-system + path: /validate-servicebinding-io-v1beta1-clusterworkloadresourcemapping + failurePolicy: Fail + name: v1beta1.clusterworkloadresourcemappings.servicebinding.io + rules: + - apiGroups: + - servicebinding.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - clusterworkloadresourcemappings + sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta1 + clientConfig: + service: + name: servicebinding-webhook-service + namespace: servicebinding-system + path: /validate-servicebinding-io-v1beta1-servicebinding + failurePolicy: Fail + name: v1beta1.servicebindings.servicebinding.io + rules: + - apiGroups: + - servicebinding.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - servicebindings + sideEffects: None diff --git a/config/servicebinding-workloadresourcemappings.yaml b/config/servicebinding-workloadresourcemappings.yaml index 9dd022dd..368a52c4 100644 --- a/config/servicebinding-workloadresourcemappings.yaml +++ b/config/servicebinding-workloadresourcemappings.yaml @@ -16,7 +16,7 @@ # see https://servicebinding.io/spec/core/1.0.0/#workload-resource-mapping --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ClusterWorkloadResourceMapping metadata: name: cronjobs.batch diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index a3f64d94..b169e602 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -11,14 +11,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-servicebinding-io-v1beta1-clusterworkloadresourcemapping + path: /validate-servicebinding-io-v1-clusterworkloadresourcemapping failurePolicy: Fail - name: v1beta1.clusterworkloadresourcemappings.servicebinding.io + name: v1.clusterworkloadresourcemappings.servicebinding.io rules: - apiGroups: - servicebinding.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -32,14 +32,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-servicebinding-io-v1beta1-servicebinding + path: /validate-servicebinding-io-v1-servicebinding failurePolicy: Fail - name: v1beta1.servicebindings.servicebinding.io + name: v1.servicebindings.servicebinding.io rules: - apiGroups: - servicebinding.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -88,3 +88,45 @@ webhooks: resources: - servicebindings sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-servicebinding-io-v1beta1-clusterworkloadresourcemapping + failurePolicy: Fail + name: v1beta1.clusterworkloadresourcemappings.servicebinding.io + rules: + - apiGroups: + - servicebinding.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - clusterworkloadresourcemappings + sideEffects: None +- admissionReviewVersions: + - v1 + - v1beta1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-servicebinding-io-v1beta1-servicebinding + failurePolicy: Fail + name: v1beta1.servicebindings.servicebinding.io + rules: + - apiGroups: + - servicebinding.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - servicebindings + sideEffects: None diff --git a/controllers/servicebinding_controller.go b/controllers/servicebinding_controller.go index c5f1757b..7b3f793f 100644 --- a/controllers/servicebinding_controller.go +++ b/controllers/servicebinding_controller.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/lifecycle" ) @@ -43,11 +43,11 @@ import ( //+kubebuilder:rbac:groups=core,resources=events,verbs=get;list;watch;create;update;patch;delete // ServiceBindingReconciler reconciles a ServiceBinding object -func ServiceBindingReconciler(c reconcilers.Config, hooks lifecycle.ServiceBindingHooks) *reconcilers.ResourceReconciler[*servicebindingv1beta1.ServiceBinding] { - return &reconcilers.ResourceReconciler[*servicebindingv1beta1.ServiceBinding]{ - Reconciler: &reconcilers.WithFinalizer[*servicebindingv1beta1.ServiceBinding]{ - Finalizer: servicebindingv1beta1.GroupVersion.Group + "/finalizer", - Reconciler: reconcilers.Sequence[*servicebindingv1beta1.ServiceBinding]{ +func ServiceBindingReconciler(c reconcilers.Config, hooks lifecycle.ServiceBindingHooks) *reconcilers.ResourceReconciler[*servicebindingv1.ServiceBinding] { + return &reconcilers.ResourceReconciler[*servicebindingv1.ServiceBinding]{ + Reconciler: &reconcilers.WithFinalizer[*servicebindingv1.ServiceBinding]{ + Finalizer: servicebindingv1.GroupVersion.Group + "/finalizer", + Reconciler: reconcilers.Sequence[*servicebindingv1.ServiceBinding]{ ResolveBindingSecret(hooks), ResolveWorkloads(hooks), ProjectBinding(hooks), @@ -59,23 +59,23 @@ func ServiceBindingReconciler(c reconcilers.Config, hooks lifecycle.ServiceBindi } } -func ResolveBindingSecret(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { - return &reconcilers.SyncReconciler[*servicebindingv1beta1.ServiceBinding]{ +func ResolveBindingSecret(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { + return &reconcilers.SyncReconciler[*servicebindingv1.ServiceBinding]{ Name: "ResolveBindingSecret", - Sync: func(ctx context.Context, resource *servicebindingv1beta1.ServiceBinding) error { + Sync: func(ctx context.Context, resource *servicebindingv1.ServiceBinding) error { c := reconcilers.RetrieveConfigOrDie(ctx) secretName, err := hooks.GetResolver(TrackingClient(c)).LookupBindingSecret(ctx, resource) if err != nil { if apierrs.IsNotFound(err) { // leave Unknown, the provisioned service may be created shortly - resource.GetConditionManager().MarkUnknown(servicebindingv1beta1.ServiceBindingConditionServiceAvailable, "ServiceNotFound", "the service was not found") + resource.GetConditionManager().MarkUnknown(servicebindingv1.ServiceBindingConditionServiceAvailable, "ServiceNotFound", "the service was not found") return nil } if apierrs.IsForbidden(err) { // set False, the operator needs to give access to the resource // see https://servicebinding.io/spec/core/1.0.0/#considerations-for-role-based-access-control-rbac - resource.GetConditionManager().MarkFalse(servicebindingv1beta1.ServiceBindingConditionServiceAvailable, "ServiceForbidden", "the controller does not have permission to get the service") + resource.GetConditionManager().MarkFalse(servicebindingv1.ServiceBindingConditionServiceAvailable, "ServiceForbidden", "the controller does not have permission to get the service") return nil } // TODO handle other err cases @@ -84,12 +84,12 @@ func ResolveBindingSecret(hooks lifecycle.ServiceBindingHooks) reconcilers.SubRe if secretName != "" { // success - resource.GetConditionManager().MarkTrue(servicebindingv1beta1.ServiceBindingConditionServiceAvailable, "ResolvedBindingSecret", "") + resource.GetConditionManager().MarkTrue(servicebindingv1.ServiceBindingConditionServiceAvailable, "ResolvedBindingSecret", "") previousSecretName := "" if resource.Status.Binding != nil { previousSecretName = resource.Status.Binding.Name } - resource.Status.Binding = &servicebindingv1beta1.ServiceBindingSecretReference{Name: secretName} + resource.Status.Binding = &servicebindingv1.ServiceBindingSecretReference{Name: secretName} if previousSecretName != secretName { // stop processing subreconcilers, we need to allow the secret to be updated on // the API Server so that webhook calls for workload that are targeted by the @@ -101,7 +101,7 @@ func ResolveBindingSecret(hooks lifecycle.ServiceBindingHooks) reconcilers.SubRe } } else { // leave Unknown, not success but also not an error - resource.GetConditionManager().MarkUnknown(servicebindingv1beta1.ServiceBindingConditionServiceAvailable, "ServiceMissingBinding", "the service was found, but did not contain a binding secret") + resource.GetConditionManager().MarkUnknown(servicebindingv1.ServiceBindingConditionServiceAvailable, "ServiceMissingBinding", "the service was found, but did not contain a binding secret") // TODO should we clear the existing binding? resource.Status.Binding = nil } @@ -111,11 +111,11 @@ func ResolveBindingSecret(hooks lifecycle.ServiceBindingHooks) reconcilers.SubRe } } -func ResolveWorkloads(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { - return &reconcilers.SyncReconciler[*servicebindingv1beta1.ServiceBinding]{ +func ResolveWorkloads(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { + return &reconcilers.SyncReconciler[*servicebindingv1.ServiceBinding]{ Name: "ResolveWorkloads", SyncDuringFinalization: true, - SyncWithResult: func(ctx context.Context, resource *servicebindingv1beta1.ServiceBinding) (reconcile.Result, error) { + SyncWithResult: func(ctx context.Context, resource *servicebindingv1.ServiceBinding) (reconcile.Result, error) { c := reconcilers.RetrieveConfigOrDie(ctx) trackingRef := tracker.Reference{ @@ -142,9 +142,9 @@ func ResolveWorkloads(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconc // set False, the operator needs to give access to the resource // see https://servicebinding.io/spec/core/1.0.0/#considerations-for-role-based-access-control-rbac-1 if resource.Spec.Workload.Name == "" { - resource.GetConditionManager().MarkFalse(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to list the workloads") + resource.GetConditionManager().MarkFalse(servicebindingv1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to list the workloads") } else { - resource.GetConditionManager().MarkFalse(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to get the workload") + resource.GetConditionManager().MarkFalse(servicebindingv1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to get the workload") } return reconcile.Result{}, nil } @@ -161,7 +161,7 @@ func ResolveWorkloads(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconc } if !found { // leave Unknown, the workload may be created shortly - resource.GetConditionManager().MarkUnknown(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected, "WorkloadNotFound", "the workload was not found") + resource.GetConditionManager().MarkUnknown(servicebindingv1.ServiceBindingConditionWorkloadProjected, "WorkloadNotFound", "the workload was not found") } } @@ -174,11 +174,11 @@ func ResolveWorkloads(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconc //+kubebuilder:rbac:groups=servicebinding.io,resources=clusterworkloadresourcemappings,verbs=get;list;watch -func ProjectBinding(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { - return &reconcilers.SyncReconciler[*servicebindingv1beta1.ServiceBinding]{ +func ProjectBinding(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { + return &reconcilers.SyncReconciler[*servicebindingv1.ServiceBinding]{ Name: "ProjectBinding", SyncDuringFinalization: true, - Sync: func(ctx context.Context, resource *servicebindingv1beta1.ServiceBinding) error { + Sync: func(ctx context.Context, resource *servicebindingv1.ServiceBinding) error { c := reconcilers.RetrieveConfigOrDie(ctx) projector := hooks.GetProjector(hooks.GetResolver(TrackingClient(c))) @@ -227,13 +227,13 @@ func ProjectBinding(hooks lifecycle.ServiceBindingHooks) reconcilers.SubReconcil }, Setup: func(ctx context.Context, mgr ctlr.Manager, bldr *builder.Builder) error { - bldr.Watches(&servicebindingv1beta1.ClusterWorkloadResourceMapping{}, handler.Funcs{}) + bldr.Watches(&servicebindingv1.ClusterWorkloadResourceMapping{}, handler.Funcs{}) return nil }, } } -func PatchWorkloads() reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { +func PatchWorkloads() reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { workloadManager := &reconcilers.ResourceManager[*unstructured.Unstructured]{ Name: "PatchWorkloads", MergeBeforeUpdate: func(current, desired *unstructured.Unstructured) { @@ -241,10 +241,10 @@ func PatchWorkloads() reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBi }, } - return &reconcilers.SyncReconciler[*servicebindingv1beta1.ServiceBinding]{ + return &reconcilers.SyncReconciler[*servicebindingv1.ServiceBinding]{ Name: "PatchWorkloads", SyncDuringFinalization: true, - Sync: func(ctx context.Context, resource *servicebindingv1beta1.ServiceBinding) error { + Sync: func(ctx context.Context, resource *servicebindingv1.ServiceBinding) error { workloads := RetrieveWorkloads(ctx) projectedWorkloads := RetrieveProjectedWorkloads(ctx) @@ -267,7 +267,7 @@ func PatchWorkloads() reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBi if apierrs.IsForbidden(err) { // set False, the operator needs to give access to the resource // see https://servicebinding.io/spec/core/1.0.0/#considerations-for-role-based-access-control-rbac-1 - resource.GetConditionManager().MarkFalse(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to update the workloads") + resource.GetConditionManager().MarkFalse(servicebindingv1.ServiceBindingConditionWorkloadProjected, "WorkloadForbidden", "the controller does not have permission to update the workloads") return nil } // TODO handle other err cases @@ -276,8 +276,8 @@ func PatchWorkloads() reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBi } // update the WorkloadProjected condition to indicate success, but only if the condition has not already been set with another status - if cond := resource.Status.GetCondition(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected); apis.ConditionIsUnknown(cond) && cond.Reason == "Initializing" { - resource.GetConditionManager().MarkTrue(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected, "WorkloadProjected", "") + if cond := resource.Status.GetCondition(servicebindingv1.ServiceBindingConditionWorkloadProjected); apis.ConditionIsUnknown(cond) && cond.Reason == "Initializing" { + resource.GetConditionManager().MarkTrue(servicebindingv1.ServiceBindingConditionWorkloadProjected, "WorkloadProjected", "") } return nil diff --git a/controllers/servicebinding_controller_test.go b/controllers/servicebinding_controller_test.go index 77046d26..74484dfa 100644 --- a/controllers/servicebinding_controller_test.go +++ b/controllers/servicebinding_controller_test.go @@ -44,9 +44,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/controllers" - dieservicebindingv1beta1 "github.com/servicebinding/runtime/dies/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" "github.com/servicebinding/runtime/lifecycle" ) @@ -61,30 +61,30 @@ func TestServiceBindingReconciler(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) now := metav1.Now().Rfc3339Copy() - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.UID(uid) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("v1") d.Kind("Secret") d.Name(secretName) }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") }) }) - workloadMapping := dieservicebindingv1beta1.ClusterWorkloadResourceMappingBlank. + workloadMapping := dieservicebindingv1.ClusterWorkloadResourceMappingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Name("deployments.apps") }) @@ -164,20 +164,20 @@ func TestServiceBindingReconciler(t *testing.T) { "in sync": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -191,7 +191,7 @@ func TestServiceBindingReconciler(t *testing.T) { "newly created, resolves secret": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding, @@ -213,13 +213,13 @@ func TestServiceBindingReconciler(t *testing.T) { }, ExpectStatusUpdates: []client.Object{ serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.Unknown().Reason("Initializing"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.Unknown().Reason("Initializing"), + dieservicebindingv1.ServiceBindingConditionReady.Unknown().Reason("Initializing"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.Unknown().Reason("Initializing"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -228,15 +228,15 @@ func TestServiceBindingReconciler(t *testing.T) { "has resolved secret, project into workload": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -255,13 +255,13 @@ func TestServiceBindingReconciler(t *testing.T) { }, ExpectStatusUpdates: []client.Object{ serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -270,25 +270,25 @@ func TestServiceBindingReconciler(t *testing.T) { "switch bound workload": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.Name("new-workload") }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -323,7 +323,7 @@ func TestServiceBindingReconciler(t *testing.T) { "terminating": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. @@ -370,20 +370,20 @@ func TestResolveBindingSecret(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) }) secretName := "my-secret" - directSecretRef := dieservicebindingv1beta1.ServiceBindingServiceReferenceBlank. + directSecretRef := dieservicebindingv1.ServiceBindingServiceReferenceBlank. APIVersion("v1"). Kind("Secret"). Name(secretName) - serviceRef := dieservicebindingv1beta1.ServiceBindingServiceReferenceBlank. + serviceRef := dieservicebindingv1.ServiceBindingServiceReferenceBlank. APIVersion("example/v1"). Kind("MyProvisionedService"). Name("my-service") @@ -400,18 +400,18 @@ func TestResolveBindingSecret(t *testing.T) { }, } - rts := rtesting.SubReconcilerTests[*servicebindingv1beta1.ServiceBinding]{ + rts := rtesting.SubReconcilerTests[*servicebindingv1.ServiceBinding]{ "in sync": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(directSecretRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. True().Reason("ResolvedBindingSecret"), ) }). @@ -419,20 +419,20 @@ func TestResolveBindingSecret(t *testing.T) { }, "resolve direct secret": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(directSecretRef.DieRelease()) }). DieReleasePtr(), ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(directSecretRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. True().Reason("ResolvedBindingSecret"), ) }). @@ -446,7 +446,7 @@ func TestResolveBindingSecret(t *testing.T) { }, "service is a provisioned service": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). DieReleasePtr(), @@ -454,15 +454,15 @@ func TestResolveBindingSecret(t *testing.T) { provisionedService, }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. True().Reason("ResolvedBindingSecret"), ) }). @@ -479,7 +479,7 @@ func TestResolveBindingSecret(t *testing.T) { }, "service is not a provisioned service": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). DieReleasePtr(), @@ -487,15 +487,15 @@ func TestResolveBindingSecret(t *testing.T) { notProvisionedService, }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. Reason("ServiceMissingBinding"). Message("the service was found, but did not contain a binding secret"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. Reason("ServiceMissingBinding"). Message("the service was found, but did not contain a binding secret"), ) @@ -507,7 +507,7 @@ func TestResolveBindingSecret(t *testing.T) { }, "service not found": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). DieReleasePtr(), @@ -517,15 +517,15 @@ func TestResolveBindingSecret(t *testing.T) { }), }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. Reason("ServiceNotFound"). Message("the service was not found"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. Reason("ServiceNotFound"). Message("the service was not found"), ) @@ -537,7 +537,7 @@ func TestResolveBindingSecret(t *testing.T) { }, "service forbidden": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). DieReleasePtr(), @@ -547,16 +547,16 @@ func TestResolveBindingSecret(t *testing.T) { }), }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. False(). Reason("ServiceForbidden"). Message("the controller does not have permission to get the service"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. False(). Reason("ServiceForbidden"). Message("the controller does not have permission to get the service"), @@ -569,7 +569,7 @@ func TestResolveBindingSecret(t *testing.T) { }, "service generic get error": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Service(serviceRef.DieRelease()) }). DieReleasePtr(), @@ -583,7 +583,7 @@ func TestResolveBindingSecret(t *testing.T) { }, } - rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { + rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { return controllers.ResolveBindingSecret(lifecycle.ServiceBindingHooks{}) }) } @@ -594,9 +594,9 @@ func TestResolveWorkload(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) @@ -624,11 +624,11 @@ func TestResolveWorkload(t *testing.T) { d.AddLabel("app", "not") }) - rts := rtesting.SubReconcilerTests[*servicebindingv1beta1.ServiceBinding]{ + rts := rtesting.SubReconcilerTests[*servicebindingv1.ServiceBinding]{ "resolve named workload": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload-1") @@ -651,8 +651,8 @@ func TestResolveWorkload(t *testing.T) { }, "resolve named workload not found": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload-1") @@ -660,18 +660,18 @@ func TestResolveWorkload(t *testing.T) { }). DieReleasePtr(), ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload-1") }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. Reason("WorkloadNotFound").Message("the workload was not found"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected. + dieservicebindingv1.ServiceBindingConditionWorkloadProjected. Reason("WorkloadNotFound").Message("the workload was not found"), ) }). @@ -682,8 +682,8 @@ func TestResolveWorkload(t *testing.T) { }, "resolve named workload forbidden": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload-1") @@ -701,20 +701,20 @@ func TestResolveWorkload(t *testing.T) { }), }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload-1") }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to get the workload"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected. + dieservicebindingv1.ServiceBindingConditionWorkloadProjected. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to get the workload"), @@ -727,8 +727,8 @@ func TestResolveWorkload(t *testing.T) { }, "resolve selected workload": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { @@ -765,8 +765,8 @@ func TestResolveWorkload(t *testing.T) { "resolve selected workload not found": { GivenObjects: []client.Object{}, Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { @@ -794,8 +794,8 @@ func TestResolveWorkload(t *testing.T) { }, "resolve selected workload forbidden": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { @@ -815,8 +815,8 @@ func TestResolveWorkload(t *testing.T) { }), }, ExpectResource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { @@ -824,13 +824,13 @@ func TestResolveWorkload(t *testing.T) { }) }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to list the workloads"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected. + dieservicebindingv1.ServiceBindingConditionWorkloadProjected. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to list the workloads"), @@ -853,7 +853,7 @@ func TestResolveWorkload(t *testing.T) { }, } - rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { + rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { return controllers.ResolveWorkloads(lifecycle.ServiceBindingHooks{}) }) } @@ -868,31 +868,31 @@ func TestProjectBinding(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) now := metav1.Now().Rfc3339Copy() - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.UID(uid) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Name(name) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }) - workloadMapping := dieservicebindingv1beta1.ClusterWorkloadResourceMappingBlank. + workloadMapping := dieservicebindingv1.ClusterWorkloadResourceMappingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Name("deployments.apps") }) @@ -967,11 +967,11 @@ func TestProjectBinding(t *testing.T) { unstructured.SetNestedSlice(unprojectedWorkload.UnstructuredContent(), containers, "spec", "template", "spec", "containers") unstructured.SetNestedSlice(unprojectedWorkload.UnstructuredContent(), []interface{}{}, "spec", "template", "spec", "volumes") - rts := rtesting.SubReconcilerTests[*servicebindingv1beta1.ServiceBinding]{ + rts := rtesting.SubReconcilerTests[*servicebindingv1.ServiceBinding]{ "project workload": { Resource: serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(workload.GetName()) @@ -998,8 +998,8 @@ func TestProjectBinding(t *testing.T) { d.DeletionTimestamp(&now) d.Finalizers("servicebinding.io/finalizer") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(workload.GetName()) @@ -1022,7 +1022,7 @@ func TestProjectBinding(t *testing.T) { }, } - rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { + rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { restMapper := c.RESTMapper().(*meta.DefaultRESTMapper) restMapper.Add(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}, meta.RESTScopeNamespace) return controllers.ProjectBinding(lifecycle.ServiceBindingHooks{}) @@ -1037,18 +1037,18 @@ func TestPatchWorkloads(t *testing.T) { now := metav1.Now().Rfc3339Copy() scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady, - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected, + dieservicebindingv1.ServiceBindingConditionReady, + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected, ) }) @@ -1073,14 +1073,14 @@ func TestPatchWorkloads(t *testing.T) { }) }) - rts := rtesting.SubReconcilerTests[*servicebindingv1beta1.ServiceBinding]{ + rts := rtesting.SubReconcilerTests[*servicebindingv1.ServiceBinding]{ "in sync": { Resource: serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) }). DieReleasePtr(), @@ -1115,11 +1115,11 @@ func TestPatchWorkloads(t *testing.T) { }, }, ExpectResource: serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) }). DieReleasePtr(), @@ -1150,11 +1150,11 @@ func TestPatchWorkloads(t *testing.T) { }, }, ExpectResource: serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) }). DieReleasePtr(), @@ -1193,16 +1193,16 @@ func TestPatchWorkloads(t *testing.T) { }), }, ExpectResource: serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady. + dieservicebindingv1.ServiceBindingConditionReady. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to update the workloads"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable. + dieservicebindingv1.ServiceBindingConditionServiceAvailable. True(). Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected. + dieservicebindingv1.ServiceBindingConditionWorkloadProjected. False(). Reason("WorkloadForbidden"). Message("the controller does not have permission to update the workloads"), @@ -1275,7 +1275,7 @@ func TestPatchWorkloads(t *testing.T) { }, } - rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { + rts.Run(t, scheme, func(t *testing.T, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { return controllers.PatchWorkloads() }) } diff --git a/controllers/webhook_controller.go b/controllers/webhook_controller.go index 1669b8e0..47e47e90 100644 --- a/controllers/webhook_controller.go +++ b/controllers/webhook_controller.go @@ -38,7 +38,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/lifecycle" "github.com/servicebinding/runtime/rbac" ) @@ -88,7 +88,7 @@ func AdmissionProjectorReconciler(c reconcilers.Config, name string, accessCheck }, Setup: func(ctx context.Context, mgr controllerruntime.Manager, bldr *builder.Builder) error { - if err := mgr.GetFieldIndexer().IndexField(ctx, &servicebindingv1beta1.ServiceBinding{}, WorkloadRefIndexKey, WorkloadRefIndexFunc); err != nil { + if err := mgr.GetFieldIndexer().IndexField(ctx, &servicebindingv1.ServiceBinding{}, WorkloadRefIndexKey, WorkloadRefIndexFunc); err != nil { return err } return nil @@ -105,7 +105,7 @@ func AdmissionProjectorWebhook(c reconcilers.Config, hooks lifecycle.ServiceBind c := reconcilers.RetrieveConfigOrDie(ctx) // find matching service bindings - serviceBindings := &servicebindingv1beta1.ServiceBindingList{} + serviceBindings := &servicebindingv1.ServiceBindingList{} gvk := schema.FromAPIVersionAndKind(workload.GetAPIVersion(), workload.GetKind()) if err := c.List(ctx, serviceBindings, client.InNamespace(workload.GetNamespace()), client.MatchingFields{WorkloadRefIndexKey: workloadRefIndexValue(gvk.Group, gvk.Kind)}); err != nil { return err @@ -114,7 +114,7 @@ func AdmissionProjectorWebhook(c reconcilers.Config, hooks lifecycle.ServiceBind projector := hooks.GetProjector(hooks.GetResolver(c)) // check that bindings are for this workload - activeServiceBindings := []servicebindingv1beta1.ServiceBinding{} + activeServiceBindings := []servicebindingv1.ServiceBinding{} for _, sb := range serviceBindings.Items { if !sb.DeletionTimestamp.IsZero() { continue @@ -269,7 +269,7 @@ func LoadServiceBindings(req reconcile.Request) reconcilers.SubReconciler[client Sync: func(ctx context.Context, _ client.Object) error { c := reconcilers.RetrieveConfigOrDie(ctx) - serviceBindings := &servicebindingv1beta1.ServiceBindingList{} + serviceBindings := &servicebindingv1.ServiceBindingList{} if err := c.List(ctx, serviceBindings); err != nil { return err } @@ -279,7 +279,7 @@ func LoadServiceBindings(req reconcile.Request) reconcilers.SubReconciler[client return nil }, Setup: func(ctx context.Context, mgr controllerruntime.Manager, bldr *builder.Builder) error { - bldr.Watches(&servicebindingv1beta1.ServiceBinding{}, handler.EnqueueRequestsFromMapFunc( + bldr.Watches(&servicebindingv1.ServiceBinding{}, handler.EnqueueRequestsFromMapFunc( func(ctx context.Context, o client.Object) []reconcile.Request { return []reconcile.Request{req} }, @@ -403,13 +403,13 @@ func WebhookRules(operations []admissionregistrationv1.OperationType, subresourc const ServiceBindingsStashKey reconcilers.StashKey = "servicebinding.io:servicebindings" -func StashServiceBindings(ctx context.Context, serviceBindings []servicebindingv1beta1.ServiceBinding) { +func StashServiceBindings(ctx context.Context, serviceBindings []servicebindingv1.ServiceBinding) { reconcilers.StashValue(ctx, ServiceBindingsStashKey, serviceBindings) } -func RetrieveServiceBindings(ctx context.Context) []servicebindingv1beta1.ServiceBinding { +func RetrieveServiceBindings(ctx context.Context) []servicebindingv1.ServiceBinding { value := reconcilers.RetrieveValue(ctx, ServiceBindingsStashKey) - if serviceBindings, ok := value.([]servicebindingv1beta1.ServiceBinding); ok { + if serviceBindings, ok := value.([]servicebindingv1.ServiceBinding); ok { return serviceBindings } return nil @@ -446,7 +446,7 @@ func RetrieveWebhookRules(ctx context.Context) []admissionregistrationv1.RuleWit const WorkloadRefIndexKey = ".metadata.workloadRef" func WorkloadRefIndexFunc(obj client.Object) []string { - serviceBinding := obj.(*servicebindingv1beta1.ServiceBinding) + serviceBinding := obj.(*servicebindingv1.ServiceBinding) gvk := schema.FromAPIVersionAndKind(serviceBinding.Spec.Workload.APIVersion, serviceBinding.Spec.Workload.Kind) return []string{ workloadRefIndexValue(gvk.Group, gvk.Kind), diff --git a/controllers/webhook_controller_test.go b/controllers/webhook_controller_test.go index 1da6f7c7..15fdc534 100644 --- a/controllers/webhook_controller_test.go +++ b/controllers/webhook_controller_test.go @@ -52,9 +52,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/source" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/controllers" - dieservicebindingv1beta1 "github.com/servicebinding/runtime/dies/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" "github.com/servicebinding/runtime/lifecycle" "github.com/servicebinding/runtime/rbac" ) @@ -65,7 +65,7 @@ func TestAdmissionProjectorReconciler(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.MutatingWebhookConfigurationBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { @@ -90,18 +90,18 @@ func TestAdmissionProjectorReconciler(t *testing.T) { ) }) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace("my-namespace") d.Name("my-binding") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("example/v1") d.Kind("MyService") d.Name("my-service") }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -186,7 +186,7 @@ func TestAdmissionProjectorWebhook(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) requestUID := types.UID("9deefaa1-2c90-4f40-9c7b-3f5c1fd75dde") bindingUID := types.UID("89deaf20-7bab-4610-81db-6f8c3f7fa51d") @@ -209,14 +209,14 @@ func TestAdmissionProjectorWebhook(t *testing.T) { }) }) }) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.UID(bindingUID) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secret) }) }) @@ -228,7 +228,7 @@ func TestAdmissionProjectorWebhook(t *testing.T) { Allowed(true) addWorkloadRefIndex := func(cb *fake.ClientBuilder) *fake.ClientBuilder { - return cb.WithIndex(&servicebindingv1beta1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) + return cb.WithIndex(&servicebindingv1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) } wts := rtesting.AdmissionWebhookTests{ @@ -239,8 +239,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Name(fmt.Sprintf("%s-named", name)) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.Name("some-other-workload") }) }), @@ -248,8 +248,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Name(fmt.Sprintf("%s-selected", name)) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { d.AddMatchLabel("some-other-workload", "true") }) @@ -268,8 +268,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { "binding already projected": { WithClientBuilder: addWorkloadRefIndex, GivenObjects: []client.Object{ - serviceBinding.SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + serviceBinding.SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(name) @@ -323,8 +323,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { "binding projected by name": { WithClientBuilder: addWorkloadRefIndex, GivenObjects: []client.Object{ - serviceBinding.SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + serviceBinding.SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(name) @@ -398,8 +398,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { "binding projected by selector": { WithClientBuilder: addWorkloadRefIndex, GivenObjects: []client.Object{ - serviceBinding.SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + serviceBinding.SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Selector(&metav1.LabelSelector{}) @@ -479,8 +479,8 @@ func TestAdmissionProjectorWebhook(t *testing.T) { d.DeletionTimestamp(&now) d.Finalizers("servicebinding.io/finalizer") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(name) @@ -530,7 +530,7 @@ func TestTriggerReconciler(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.ValidatingWebhookConfigurationBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { @@ -565,18 +565,18 @@ func TestTriggerReconciler(t *testing.T) { ) }) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace("my-namespace") d.Name("my-binding") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("example/v1") d.Kind("MyService") d.Name("my-service") }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -671,11 +671,11 @@ func TestTriggerWebhook(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) requestUID := types.UID("9deefaa1-2c90-4f40-9c7b-3f5c1fd75dde") - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(bindingName) @@ -772,22 +772,22 @@ func TestTriggerWebhook(t *testing.T) { func TestLoadServiceBindings(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.ValidatingWebhookConfigurationBlank - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace("my-namespace") d.Name("my-binding") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("example/v1") d.Kind("MyService") d.Name("my-service") }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -801,7 +801,7 @@ func TestLoadServiceBindings(t *testing.T) { serviceBinding, }, ExpectStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding.DieRelease(), }, }, @@ -827,22 +827,22 @@ func TestLoadServiceBindings(t *testing.T) { func TestInterceptGVKs(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.ValidatingWebhookConfigurationBlank - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace("my-namespace") d.Name("my-binding") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("example/v1") d.Kind("MyService") d.Name("my-service") }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -853,7 +853,7 @@ func TestInterceptGVKs(t *testing.T) { "collect workload gvks": { Resource: webhook, GivenStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding.DieRelease(), }, }, @@ -866,7 +866,7 @@ func TestInterceptGVKs(t *testing.T) { "append workload gvks": { Resource: webhook, GivenStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding.DieRelease(), }, controllers.ObservedGVKsStashKey: []schema.GroupVersionKind{ @@ -890,24 +890,24 @@ func TestInterceptGVKs(t *testing.T) { func TestTriggerGVKs(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.ValidatingWebhookConfigurationBlank. APIVersion("admissionregistration.k8s.io"). Kind("ValidatingWebhookConfiguration") - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace("my-namespace") d.Name("my-binding") }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("example/v1") d.Kind("MyService") d.Name("my-service") }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -918,7 +918,7 @@ func TestTriggerGVKs(t *testing.T) { "collect service gvks": { Resource: webhook, GivenStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding.DieRelease(), }, }, @@ -931,7 +931,7 @@ func TestTriggerGVKs(t *testing.T) { "append service gvks": { Resource: webhook, GivenStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding.DieRelease(), }, controllers.ObservedGVKsStashKey: []schema.GroupVersionKind{ @@ -948,10 +948,10 @@ func TestTriggerGVKs(t *testing.T) { "ignore direct binding": { Resource: webhook, GivenStashedValues: map[reconcilers.StashKey]interface{}{ - controllers.ServiceBindingsStashKey: []servicebindingv1beta1.ServiceBinding{ + controllers.ServiceBindingsStashKey: []servicebindingv1.ServiceBinding{ serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("v1") d.Kind("Secret") }) @@ -973,7 +973,7 @@ func TestTriggerGVKs(t *testing.T) { func TestWebhookRules(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) webhook := dieadmissionregistrationv1.ValidatingWebhookConfigurationBlank. APIVersion("admissionregistration.k8s.io"). diff --git a/dies/v1/clusterworkloadresourcemapping.go b/dies/v1/clusterworkloadresourcemapping.go new file mode 100644 index 00000000..8e5a631a --- /dev/null +++ b/dies/v1/clusterworkloadresourcemapping.go @@ -0,0 +1,59 @@ +/* +Copyright 2022 the original author or authors. + +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 v1 + +import ( + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" +) + +// +die:object=true +type _ = servicebindingv1.ClusterWorkloadResourceMapping + +// +die +type _ = servicebindingv1.ClusterWorkloadResourceMappingSpec + +func (d *ClusterWorkloadResourceMappingSpecDie) VersionsDie(version string, fn func(d *ClusterWorkloadResourceMappingTemplateDie)) *ClusterWorkloadResourceMappingSpecDie { + return d.DieStamp(func(r *servicebindingv1.ClusterWorkloadResourceMappingSpec) { + for i := range r.Versions { + if version == r.Versions[i].Version { + d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(r.Versions[i]) + fn(d) + r.Versions[i] = d.DieRelease() + return + } + } + + d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(servicebindingv1.ClusterWorkloadResourceMappingTemplate{Version: version}) + fn(d) + r.Versions = append(r.Versions, d.DieRelease()) + }) +} + +// +die +type _ = servicebindingv1.ClusterWorkloadResourceMappingTemplate + +func (d *ClusterWorkloadResourceMappingTemplateDie) ContainersDie(containers ...*ClusterWorkloadResourceMappingContainerDie) *ClusterWorkloadResourceMappingTemplateDie { + return d.DieStamp(func(r *servicebindingv1.ClusterWorkloadResourceMappingTemplate) { + r.Containers = make([]servicebindingv1.ClusterWorkloadResourceMappingContainer, len(containers)) + for i := range containers { + r.Containers[i] = containers[i].DieRelease() + } + }) +} + +// +die +type _ = servicebindingv1.ClusterWorkloadResourceMappingContainer diff --git a/dies/v1/servicebinding.go b/dies/v1/servicebinding.go new file mode 100644 index 00000000..f5ccb462 --- /dev/null +++ b/dies/v1/servicebinding.go @@ -0,0 +1,107 @@ +/* +Copyright 2022 the original author or authors. + +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 v1 + +import ( + diemetav1 "dies.dev/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" +) + +// +die:object=true +type _ = servicebindingv1.ServiceBinding + +// +die +type _ = servicebindingv1.ServiceBindingSpec + +func (d *ServiceBindingSpecDie) WorkloadDie(fn func(d *ServiceBindingWorkloadReferenceDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { + d := ServiceBindingWorkloadReferenceBlank.DieImmutable(false).DieFeed(r.Workload) + fn(d) + r.Workload = d.DieRelease() + }) +} + +func (d *ServiceBindingSpecDie) ServiceDie(fn func(d *ServiceBindingServiceReferenceDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { + d := ServiceBindingServiceReferenceBlank.DieImmutable(false).DieFeed(r.Service) + fn(d) + r.Service = d.DieRelease() + }) +} + +func (d *ServiceBindingSpecDie) EnvDie(name string, fn func(d *EnvMappingDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { + for i := range r.Env { + if name == r.Env[i].Name { + d := EnvMappingBlank.DieImmutable(false).DieFeed(r.Env[i]) + fn(d) + r.Env[i] = d.DieRelease() + return + } + } + + d := EnvMappingBlank.DieImmutable(false).DieFeed(servicebindingv1.EnvMapping{Name: name}) + fn(d) + r.Env = append(r.Env, d.DieRelease()) + }) +} + +// +die +type _ = servicebindingv1.ServiceBindingWorkloadReference + +func (d *ServiceBindingWorkloadReferenceDie) SelectorDie(fn func(d *diemetav1.LabelSelectorDie)) *ServiceBindingWorkloadReferenceDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingWorkloadReference) { + d := diemetav1.LabelSelectorBlank.DieImmutable(false).DieFeedPtr(r.Selector) + fn(d) + r.Selector = d.DieReleasePtr() + }) +} + +// +die +type _ = servicebindingv1.ServiceBindingServiceReference + +// +die +type _ = servicebindingv1.EnvMapping + +// +die +type _ = servicebindingv1.ServiceBindingStatus + +func (d *ServiceBindingStatusDie) ConditionsDie(conditions ...*diemetav1.ConditionDie) *ServiceBindingStatusDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingStatus) { + r.Conditions = make([]metav1.Condition, len(conditions)) + for i := range conditions { + r.Conditions[i] = conditions[i].DieRelease() + } + }) +} + +var ServiceBindingConditionReady = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionReady).Unknown().Reason("Initializing") +var ServiceBindingConditionServiceAvailable = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionServiceAvailable).Unknown().Reason("Initializing") +var ServiceBindingConditionWorkloadProjected = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionWorkloadProjected).Unknown().Reason("Initializing") + +func (d *ServiceBindingStatusDie) BindingDie(fn func(d *ServiceBindingSecretReferenceDie)) *ServiceBindingStatusDie { + return d.DieStamp(func(r *servicebindingv1.ServiceBindingStatus) { + d := ServiceBindingSecretReferenceBlank.DieImmutable(false).DieFeedPtr(r.Binding) + fn(d) + r.Binding = d.DieReleasePtr() + }) +} + +// +die +type _ = servicebindingv1.ServiceBindingSecretReference diff --git a/dies/v1beta1/zz_generated.die.go b/dies/v1/zz_generated.die.go similarity index 84% rename from dies/v1beta1/zz_generated.die.go rename to dies/v1/zz_generated.die.go index c864838c..6c91ad02 100644 --- a/dies/v1beta1/zz_generated.die.go +++ b/dies/v1/zz_generated.die.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by diegen. DO NOT EDIT. -package v1beta1 +package v1 import ( json "encoding/json" @@ -27,23 +27,23 @@ import ( osx "os" reflectx "reflect" - v1 "dies.dev/apis/meta/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "dies.dev/apis/meta/v1" + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" jsonpath "k8s.io/client-go/util/jsonpath" yaml "sigs.k8s.io/yaml" - apisv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + apisv1 "github.com/servicebinding/runtime/apis/v1" ) -var ClusterWorkloadResourceMappingBlank = (&ClusterWorkloadResourceMappingDie{}).DieFeed(apisv1beta1.ClusterWorkloadResourceMapping{}) +var ClusterWorkloadResourceMappingBlank = (&ClusterWorkloadResourceMappingDie{}).DieFeed(apisv1.ClusterWorkloadResourceMapping{}) type ClusterWorkloadResourceMappingDie struct { - v1.FrozenObjectMeta + metav1.FrozenObjectMeta mutable bool - r apisv1beta1.ClusterWorkloadResourceMapping + r apisv1.ClusterWorkloadResourceMapping } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -57,30 +57,30 @@ func (d *ClusterWorkloadResourceMappingDie) DieImmutable(immutable bool) *Cluste } // DieFeed returns a new die with the provided resource. -func (d *ClusterWorkloadResourceMappingDie) DieFeed(r apisv1beta1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { +func (d *ClusterWorkloadResourceMappingDie) DieFeed(r apisv1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { if d.mutable { - d.FrozenObjectMeta = v1.FreezeObjectMeta(r.ObjectMeta) + d.FrozenObjectMeta = metav1.FreezeObjectMeta(r.ObjectMeta) d.r = r return d } return &ClusterWorkloadResourceMappingDie{ - FrozenObjectMeta: v1.FreezeObjectMeta(r.ObjectMeta), + FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, } } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ClusterWorkloadResourceMappingDie) DieFeedPtr(r *apisv1beta1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { +func (d *ClusterWorkloadResourceMappingDie) DieFeedPtr(r *apisv1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { if r == nil { - r = &apisv1beta1.ClusterWorkloadResourceMapping{} + r = &apisv1.ClusterWorkloadResourceMapping{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ClusterWorkloadResourceMappingDie) DieFeedJSON(j []byte) *ClusterWorkloadResourceMappingDie { - r := apisv1beta1.ClusterWorkloadResourceMapping{} + r := apisv1.ClusterWorkloadResourceMapping{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -89,7 +89,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieFeedJSON(j []byte) *ClusterWorklo // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ClusterWorkloadResourceMappingDie) DieFeedYAML(y []byte) *ClusterWorkloadResourceMappingDie { - r := apisv1beta1.ClusterWorkloadResourceMapping{} + r := apisv1.ClusterWorkloadResourceMapping{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -115,7 +115,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieFeedRawExtension(raw runtime.RawE } // DieRelease returns the resource managed by the die. -func (d *ClusterWorkloadResourceMappingDie) DieRelease() apisv1beta1.ClusterWorkloadResourceMapping { +func (d *ClusterWorkloadResourceMappingDie) DieRelease() apisv1.ClusterWorkloadResourceMapping { if d.mutable { return d.r } @@ -123,7 +123,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieRelease() apisv1beta1.ClusterWork } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ClusterWorkloadResourceMappingDie) DieReleasePtr() *apisv1beta1.ClusterWorkloadResourceMapping { +func (d *ClusterWorkloadResourceMappingDie) DieReleasePtr() *apisv1.ClusterWorkloadResourceMapping { r := d.DieRelease() return &r } @@ -171,7 +171,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieReleaseRawExtension() runtime.Raw } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ClusterWorkloadResourceMappingDie) DieStamp(fn func(r *apisv1beta1.ClusterWorkloadResourceMapping)) *ClusterWorkloadResourceMappingDie { +func (d *ClusterWorkloadResourceMappingDie) DieStamp(fn func(r *apisv1.ClusterWorkloadResourceMapping)) *ClusterWorkloadResourceMappingDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -181,7 +181,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieStamp(fn func(r *apisv1beta1.Clus // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ClusterWorkloadResourceMappingDie) DieStampAt(jp string, fn interface{}) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -230,7 +230,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieWith(fns ...func(d *ClusterWorklo func (d *ClusterWorkloadResourceMappingDie) DeepCopy() *ClusterWorkloadResourceMappingDie { r := *d.r.DeepCopy() return &ClusterWorkloadResourceMappingDie{ - FrozenObjectMeta: v1.FreezeObjectMeta(r.ObjectMeta), + FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, } @@ -258,7 +258,7 @@ func (d *ClusterWorkloadResourceMappingDie) UnmarshalJSON(b []byte) error { if !d.mutable { return fmtx.Errorf("cannot unmarshal into immutable dies, create a mutable version first") } - r := &apisv1beta1.ClusterWorkloadResourceMapping{} + r := &apisv1.ClusterWorkloadResourceMapping{} err := json.Unmarshal(b, r) *d = *d.DieFeed(*r) return err @@ -266,22 +266,22 @@ func (d *ClusterWorkloadResourceMappingDie) UnmarshalJSON(b []byte) error { // 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 func (d *ClusterWorkloadResourceMappingDie) APIVersion(v string) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { r.APIVersion = v }) } // 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 func (d *ClusterWorkloadResourceMappingDie) Kind(v string) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { r.Kind = v }) } // MetadataDie stamps the resource's ObjectMeta field with a mutable die. -func (d *ClusterWorkloadResourceMappingDie) MetadataDie(fn func(d *v1.ObjectMetaDie)) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { - d := v1.ObjectMetaBlank.DieImmutable(false).DieFeed(r.ObjectMeta) +func (d *ClusterWorkloadResourceMappingDie) MetadataDie(fn func(d *metav1.ObjectMetaDie)) *ClusterWorkloadResourceMappingDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { + d := metav1.ObjectMetaBlank.DieImmutable(false).DieFeed(r.ObjectMeta) fn(d) r.ObjectMeta = d.DieRelease() }) @@ -289,24 +289,24 @@ func (d *ClusterWorkloadResourceMappingDie) MetadataDie(fn func(d *v1.ObjectMeta // SpecDie stamps the resource's spec field with a mutable die. func (d *ClusterWorkloadResourceMappingDie) SpecDie(fn func(d *ClusterWorkloadResourceMappingSpecDie)) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { d := ClusterWorkloadResourceMappingSpecBlank.DieImmutable(false).DieFeed(r.Spec) fn(d) r.Spec = d.DieRelease() }) } -func (d *ClusterWorkloadResourceMappingDie) Spec(v apisv1beta1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMapping) { +func (d *ClusterWorkloadResourceMappingDie) Spec(v apisv1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { r.Spec = v }) } -var ClusterWorkloadResourceMappingSpecBlank = (&ClusterWorkloadResourceMappingSpecDie{}).DieFeed(apisv1beta1.ClusterWorkloadResourceMappingSpec{}) +var ClusterWorkloadResourceMappingSpecBlank = (&ClusterWorkloadResourceMappingSpecDie{}).DieFeed(apisv1.ClusterWorkloadResourceMappingSpec{}) type ClusterWorkloadResourceMappingSpecDie struct { mutable bool - r apisv1beta1.ClusterWorkloadResourceMappingSpec + r apisv1.ClusterWorkloadResourceMappingSpec } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -320,7 +320,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieImmutable(immutable bool) *Cl } // DieFeed returns a new die with the provided resource. -func (d *ClusterWorkloadResourceMappingSpecDie) DieFeed(r apisv1beta1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { +func (d *ClusterWorkloadResourceMappingSpecDie) DieFeed(r apisv1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { if d.mutable { d.r = r return d @@ -332,16 +332,16 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieFeed(r apisv1beta1.ClusterWor } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedPtr(r *apisv1beta1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { +func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedPtr(r *apisv1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { if r == nil { - r = &apisv1beta1.ClusterWorkloadResourceMappingSpec{} + r = &apisv1.ClusterWorkloadResourceMappingSpec{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedJSON(j []byte) *ClusterWorkloadResourceMappingSpecDie { - r := apisv1beta1.ClusterWorkloadResourceMappingSpec{} + r := apisv1.ClusterWorkloadResourceMappingSpec{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -350,7 +350,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedJSON(j []byte) *ClusterWo // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedYAML(y []byte) *ClusterWorkloadResourceMappingSpecDie { - r := apisv1beta1.ClusterWorkloadResourceMappingSpec{} + r := apisv1.ClusterWorkloadResourceMappingSpec{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -376,7 +376,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieFeedRawExtension(raw runtime. } // DieRelease returns the resource managed by the die. -func (d *ClusterWorkloadResourceMappingSpecDie) DieRelease() apisv1beta1.ClusterWorkloadResourceMappingSpec { +func (d *ClusterWorkloadResourceMappingSpecDie) DieRelease() apisv1.ClusterWorkloadResourceMappingSpec { if d.mutable { return d.r } @@ -384,7 +384,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieRelease() apisv1beta1.Cluster } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ClusterWorkloadResourceMappingSpecDie) DieReleasePtr() *apisv1beta1.ClusterWorkloadResourceMappingSpec { +func (d *ClusterWorkloadResourceMappingSpecDie) DieReleasePtr() *apisv1.ClusterWorkloadResourceMappingSpec { r := d.DieRelease() return &r } @@ -420,7 +420,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieReleaseRawExtension() runtime } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ClusterWorkloadResourceMappingSpecDie) DieStamp(fn func(r *apisv1beta1.ClusterWorkloadResourceMappingSpec)) *ClusterWorkloadResourceMappingSpecDie { +func (d *ClusterWorkloadResourceMappingSpecDie) DieStamp(fn func(r *apisv1.ClusterWorkloadResourceMappingSpec)) *ClusterWorkloadResourceMappingSpecDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -430,7 +430,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieStamp(fn func(r *apisv1beta1. // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ClusterWorkloadResourceMappingSpecDie) DieStampAt(jp string, fn interface{}) *ClusterWorkloadResourceMappingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingSpec) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingSpec) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -485,17 +485,17 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DeepCopy() *ClusterWorkloadResou } // Versions is the collection of versions for a given resource, with mappings. -func (d *ClusterWorkloadResourceMappingSpecDie) Versions(v ...apisv1beta1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingSpec) { +func (d *ClusterWorkloadResourceMappingSpecDie) Versions(v ...apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingSpecDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingSpec) { r.Versions = v }) } -var ClusterWorkloadResourceMappingTemplateBlank = (&ClusterWorkloadResourceMappingTemplateDie{}).DieFeed(apisv1beta1.ClusterWorkloadResourceMappingTemplate{}) +var ClusterWorkloadResourceMappingTemplateBlank = (&ClusterWorkloadResourceMappingTemplateDie{}).DieFeed(apisv1.ClusterWorkloadResourceMappingTemplate{}) type ClusterWorkloadResourceMappingTemplateDie struct { mutable bool - r apisv1beta1.ClusterWorkloadResourceMappingTemplate + r apisv1.ClusterWorkloadResourceMappingTemplate } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -509,7 +509,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieImmutable(immutable bool) } // DieFeed returns a new die with the provided resource. -func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeed(r apisv1beta1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { +func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeed(r apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { if d.mutable { d.r = r return d @@ -521,16 +521,16 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeed(r apisv1beta1.Cluste } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedPtr(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { +func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedPtr(r *apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { if r == nil { - r = &apisv1beta1.ClusterWorkloadResourceMappingTemplate{} + r = &apisv1.ClusterWorkloadResourceMappingTemplate{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedJSON(j []byte) *ClusterWorkloadResourceMappingTemplateDie { - r := apisv1beta1.ClusterWorkloadResourceMappingTemplate{} + r := apisv1.ClusterWorkloadResourceMappingTemplate{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -539,7 +539,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedJSON(j []byte) *Clust // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedYAML(y []byte) *ClusterWorkloadResourceMappingTemplateDie { - r := apisv1beta1.ClusterWorkloadResourceMappingTemplate{} + r := apisv1.ClusterWorkloadResourceMappingTemplate{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -565,7 +565,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeedRawExtension(raw runt } // DieRelease returns the resource managed by the die. -func (d *ClusterWorkloadResourceMappingTemplateDie) DieRelease() apisv1beta1.ClusterWorkloadResourceMappingTemplate { +func (d *ClusterWorkloadResourceMappingTemplateDie) DieRelease() apisv1.ClusterWorkloadResourceMappingTemplate { if d.mutable { return d.r } @@ -573,7 +573,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieRelease() apisv1beta1.Clu } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ClusterWorkloadResourceMappingTemplateDie) DieReleasePtr() *apisv1beta1.ClusterWorkloadResourceMappingTemplate { +func (d *ClusterWorkloadResourceMappingTemplateDie) DieReleasePtr() *apisv1.ClusterWorkloadResourceMappingTemplate { r := d.DieRelease() return &r } @@ -609,7 +609,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieReleaseRawExtension() run } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ClusterWorkloadResourceMappingTemplateDie) DieStamp(fn func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate)) *ClusterWorkloadResourceMappingTemplateDie { +func (d *ClusterWorkloadResourceMappingTemplateDie) DieStamp(fn func(r *apisv1.ClusterWorkloadResourceMappingTemplate)) *ClusterWorkloadResourceMappingTemplateDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -619,7 +619,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieStamp(fn func(r *apisv1be // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ClusterWorkloadResourceMappingTemplateDie) DieStampAt(jp string, fn interface{}) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -675,37 +675,37 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DeepCopy() *ClusterWorkloadR // Version is the version of the workload resource that this mapping is for. func (d *ClusterWorkloadResourceMappingTemplateDie) Version(v string) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { r.Version = v }) } // Annotations is a Restricted JSONPath that references the annotations map within the workload resource. These annotations must end up in the resulting Pod, and are generally not the workload resource's annotations. Defaults to `.spec.template.metadata.annotations`. func (d *ClusterWorkloadResourceMappingTemplateDie) Annotations(v string) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { r.Annotations = v }) } // Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to mappings appropriate for a PodSpecable resource. -func (d *ClusterWorkloadResourceMappingTemplateDie) Containers(v ...apisv1beta1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) { +func (d *ClusterWorkloadResourceMappingTemplateDie) Containers(v ...apisv1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingTemplateDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { r.Containers = v }) } // Volumes is a Restricted JSONPath that references the slice of volumes within the workload resource. Defaults to `.spec.template.spec.volumes`. func (d *ClusterWorkloadResourceMappingTemplateDie) Volumes(v string) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingTemplate) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { r.Volumes = v }) } -var ClusterWorkloadResourceMappingContainerBlank = (&ClusterWorkloadResourceMappingContainerDie{}).DieFeed(apisv1beta1.ClusterWorkloadResourceMappingContainer{}) +var ClusterWorkloadResourceMappingContainerBlank = (&ClusterWorkloadResourceMappingContainerDie{}).DieFeed(apisv1.ClusterWorkloadResourceMappingContainer{}) type ClusterWorkloadResourceMappingContainerDie struct { mutable bool - r apisv1beta1.ClusterWorkloadResourceMappingContainer + r apisv1.ClusterWorkloadResourceMappingContainer } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -719,7 +719,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieImmutable(immutable bool } // DieFeed returns a new die with the provided resource. -func (d *ClusterWorkloadResourceMappingContainerDie) DieFeed(r apisv1beta1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { +func (d *ClusterWorkloadResourceMappingContainerDie) DieFeed(r apisv1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { if d.mutable { d.r = r return d @@ -731,16 +731,16 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieFeed(r apisv1beta1.Clust } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedPtr(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { +func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedPtr(r *apisv1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { if r == nil { - r = &apisv1beta1.ClusterWorkloadResourceMappingContainer{} + r = &apisv1.ClusterWorkloadResourceMappingContainer{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedJSON(j []byte) *ClusterWorkloadResourceMappingContainerDie { - r := apisv1beta1.ClusterWorkloadResourceMappingContainer{} + r := apisv1.ClusterWorkloadResourceMappingContainer{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -749,7 +749,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedJSON(j []byte) *Clus // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedYAML(y []byte) *ClusterWorkloadResourceMappingContainerDie { - r := apisv1beta1.ClusterWorkloadResourceMappingContainer{} + r := apisv1.ClusterWorkloadResourceMappingContainer{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -775,7 +775,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieFeedRawExtension(raw run } // DieRelease returns the resource managed by the die. -func (d *ClusterWorkloadResourceMappingContainerDie) DieRelease() apisv1beta1.ClusterWorkloadResourceMappingContainer { +func (d *ClusterWorkloadResourceMappingContainerDie) DieRelease() apisv1.ClusterWorkloadResourceMappingContainer { if d.mutable { return d.r } @@ -783,7 +783,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieRelease() apisv1beta1.Cl } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ClusterWorkloadResourceMappingContainerDie) DieReleasePtr() *apisv1beta1.ClusterWorkloadResourceMappingContainer { +func (d *ClusterWorkloadResourceMappingContainerDie) DieReleasePtr() *apisv1.ClusterWorkloadResourceMappingContainer { r := d.DieRelease() return &r } @@ -819,7 +819,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieReleaseRawExtension() ru } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ClusterWorkloadResourceMappingContainerDie) DieStamp(fn func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer)) *ClusterWorkloadResourceMappingContainerDie { +func (d *ClusterWorkloadResourceMappingContainerDie) DieStamp(fn func(r *apisv1.ClusterWorkloadResourceMappingContainer)) *ClusterWorkloadResourceMappingContainerDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -829,7 +829,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieStamp(fn func(r *apisv1b // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ClusterWorkloadResourceMappingContainerDie) DieStampAt(jp string, fn interface{}) *ClusterWorkloadResourceMappingContainerDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -885,38 +885,38 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DeepCopy() *ClusterWorkload // Path is the JSONPath within the workload resource that matches an existing fragment that is container-like. func (d *ClusterWorkloadResourceMappingContainerDie) Path(v string) *ClusterWorkloadResourceMappingContainerDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { r.Path = v }) } // Name is a Restricted JSONPath that references the name of the container with the container-like workload resource fragment. If not defined, container name filtering is ignored. func (d *ClusterWorkloadResourceMappingContainerDie) Name(v string) *ClusterWorkloadResourceMappingContainerDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { r.Name = v }) } // Env is a Restricted JSONPath that references the slice of environment variables for the container with the container-like workload resource fragment. The referenced location is created if it does not exist. Defaults to `.envs`. func (d *ClusterWorkloadResourceMappingContainerDie) Env(v string) *ClusterWorkloadResourceMappingContainerDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { r.Env = v }) } // VolumeMounts is a Restricted JSONPath that references the slice of volume mounts for the container with the container-like workload resource fragment. The referenced location is created if it does not exist. Defaults to `.volumeMounts`. func (d *ClusterWorkloadResourceMappingContainerDie) VolumeMounts(v string) *ClusterWorkloadResourceMappingContainerDie { - return d.DieStamp(func(r *apisv1beta1.ClusterWorkloadResourceMappingContainer) { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { r.VolumeMounts = v }) } -var ServiceBindingBlank = (&ServiceBindingDie{}).DieFeed(apisv1beta1.ServiceBinding{}) +var ServiceBindingBlank = (&ServiceBindingDie{}).DieFeed(apisv1.ServiceBinding{}) type ServiceBindingDie struct { - v1.FrozenObjectMeta + metav1.FrozenObjectMeta mutable bool - r apisv1beta1.ServiceBinding + r apisv1.ServiceBinding } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -930,30 +930,30 @@ func (d *ServiceBindingDie) DieImmutable(immutable bool) *ServiceBindingDie { } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingDie) DieFeed(r apisv1beta1.ServiceBinding) *ServiceBindingDie { +func (d *ServiceBindingDie) DieFeed(r apisv1.ServiceBinding) *ServiceBindingDie { if d.mutable { - d.FrozenObjectMeta = v1.FreezeObjectMeta(r.ObjectMeta) + d.FrozenObjectMeta = metav1.FreezeObjectMeta(r.ObjectMeta) d.r = r return d } return &ServiceBindingDie{ - FrozenObjectMeta: v1.FreezeObjectMeta(r.ObjectMeta), + FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, } } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingDie) DieFeedPtr(r *apisv1beta1.ServiceBinding) *ServiceBindingDie { +func (d *ServiceBindingDie) DieFeedPtr(r *apisv1.ServiceBinding) *ServiceBindingDie { if r == nil { - r = &apisv1beta1.ServiceBinding{} + r = &apisv1.ServiceBinding{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingDie) DieFeedJSON(j []byte) *ServiceBindingDie { - r := apisv1beta1.ServiceBinding{} + r := apisv1.ServiceBinding{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -962,7 +962,7 @@ func (d *ServiceBindingDie) DieFeedJSON(j []byte) *ServiceBindingDie { // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingDie) DieFeedYAML(y []byte) *ServiceBindingDie { - r := apisv1beta1.ServiceBinding{} + r := apisv1.ServiceBinding{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -988,7 +988,7 @@ func (d *ServiceBindingDie) DieFeedRawExtension(raw runtime.RawExtension) *Servi } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingDie) DieRelease() apisv1beta1.ServiceBinding { +func (d *ServiceBindingDie) DieRelease() apisv1.ServiceBinding { if d.mutable { return d.r } @@ -996,7 +996,7 @@ func (d *ServiceBindingDie) DieRelease() apisv1beta1.ServiceBinding { } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingDie) DieReleasePtr() *apisv1beta1.ServiceBinding { +func (d *ServiceBindingDie) DieReleasePtr() *apisv1.ServiceBinding { r := d.DieRelease() return &r } @@ -1044,7 +1044,7 @@ func (d *ServiceBindingDie) DieReleaseRawExtension() runtime.RawExtension { } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingDie) DieStamp(fn func(r *apisv1beta1.ServiceBinding)) *ServiceBindingDie { +func (d *ServiceBindingDie) DieStamp(fn func(r *apisv1.ServiceBinding)) *ServiceBindingDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -1054,7 +1054,7 @@ func (d *ServiceBindingDie) DieStamp(fn func(r *apisv1beta1.ServiceBinding)) *Se // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingDie) DieStampAt(jp string, fn interface{}) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { + return d.DieStamp(func(r *apisv1.ServiceBinding) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -1103,7 +1103,7 @@ func (d *ServiceBindingDie) DieWith(fns ...func(d *ServiceBindingDie)) *ServiceB func (d *ServiceBindingDie) DeepCopy() *ServiceBindingDie { r := *d.r.DeepCopy() return &ServiceBindingDie{ - FrozenObjectMeta: v1.FreezeObjectMeta(r.ObjectMeta), + FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, } @@ -1131,7 +1131,7 @@ func (d *ServiceBindingDie) UnmarshalJSON(b []byte) error { if !d.mutable { return fmtx.Errorf("cannot unmarshal into immutable dies, create a mutable version first") } - r := &apisv1beta1.ServiceBinding{} + r := &apisv1.ServiceBinding{} err := json.Unmarshal(b, r) *d = *d.DieFeed(*r) return err @@ -1139,22 +1139,22 @@ func (d *ServiceBindingDie) UnmarshalJSON(b []byte) error { // 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 func (d *ServiceBindingDie) APIVersion(v string) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { + return d.DieStamp(func(r *apisv1.ServiceBinding) { r.APIVersion = v }) } // 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 func (d *ServiceBindingDie) Kind(v string) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { + return d.DieStamp(func(r *apisv1.ServiceBinding) { r.Kind = v }) } // MetadataDie stamps the resource's ObjectMeta field with a mutable die. -func (d *ServiceBindingDie) MetadataDie(fn func(d *v1.ObjectMetaDie)) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { - d := v1.ObjectMetaBlank.DieImmutable(false).DieFeed(r.ObjectMeta) +func (d *ServiceBindingDie) MetadataDie(fn func(d *metav1.ObjectMetaDie)) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { + d := metav1.ObjectMetaBlank.DieImmutable(false).DieFeed(r.ObjectMeta) fn(d) r.ObjectMeta = d.DieRelease() }) @@ -1162,7 +1162,7 @@ func (d *ServiceBindingDie) MetadataDie(fn func(d *v1.ObjectMetaDie)) *ServiceBi // SpecDie stamps the resource's spec field with a mutable die. func (d *ServiceBindingDie) SpecDie(fn func(d *ServiceBindingSpecDie)) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { + return d.DieStamp(func(r *apisv1.ServiceBinding) { d := ServiceBindingSpecBlank.DieImmutable(false).DieFeed(r.Spec) fn(d) r.Spec = d.DieRelease() @@ -1171,30 +1171,30 @@ func (d *ServiceBindingDie) SpecDie(fn func(d *ServiceBindingSpecDie)) *ServiceB // StatusDie stamps the resource's status field with a mutable die. func (d *ServiceBindingDie) StatusDie(fn func(d *ServiceBindingStatusDie)) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { + return d.DieStamp(func(r *apisv1.ServiceBinding) { d := ServiceBindingStatusBlank.DieImmutable(false).DieFeed(r.Status) fn(d) r.Status = d.DieRelease() }) } -func (d *ServiceBindingDie) Spec(v apisv1beta1.ServiceBindingSpec) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { +func (d *ServiceBindingDie) Spec(v apisv1.ServiceBindingSpec) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { r.Spec = v }) } -func (d *ServiceBindingDie) Status(v apisv1beta1.ServiceBindingStatus) *ServiceBindingDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBinding) { +func (d *ServiceBindingDie) Status(v apisv1.ServiceBindingStatus) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { r.Status = v }) } -var ServiceBindingSpecBlank = (&ServiceBindingSpecDie{}).DieFeed(apisv1beta1.ServiceBindingSpec{}) +var ServiceBindingSpecBlank = (&ServiceBindingSpecDie{}).DieFeed(apisv1.ServiceBindingSpec{}) type ServiceBindingSpecDie struct { mutable bool - r apisv1beta1.ServiceBindingSpec + r apisv1.ServiceBindingSpec } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1208,7 +1208,7 @@ func (d *ServiceBindingSpecDie) DieImmutable(immutable bool) *ServiceBindingSpec } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingSpecDie) DieFeed(r apisv1beta1.ServiceBindingSpec) *ServiceBindingSpecDie { +func (d *ServiceBindingSpecDie) DieFeed(r apisv1.ServiceBindingSpec) *ServiceBindingSpecDie { if d.mutable { d.r = r return d @@ -1220,16 +1220,16 @@ func (d *ServiceBindingSpecDie) DieFeed(r apisv1beta1.ServiceBindingSpec) *Servi } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingSpecDie) DieFeedPtr(r *apisv1beta1.ServiceBindingSpec) *ServiceBindingSpecDie { +func (d *ServiceBindingSpecDie) DieFeedPtr(r *apisv1.ServiceBindingSpec) *ServiceBindingSpecDie { if r == nil { - r = &apisv1beta1.ServiceBindingSpec{} + r = &apisv1.ServiceBindingSpec{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingSpecDie) DieFeedJSON(j []byte) *ServiceBindingSpecDie { - r := apisv1beta1.ServiceBindingSpec{} + r := apisv1.ServiceBindingSpec{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -1238,7 +1238,7 @@ func (d *ServiceBindingSpecDie) DieFeedJSON(j []byte) *ServiceBindingSpecDie { // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingSpecDie) DieFeedYAML(y []byte) *ServiceBindingSpecDie { - r := apisv1beta1.ServiceBindingSpec{} + r := apisv1.ServiceBindingSpec{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -1264,7 +1264,7 @@ func (d *ServiceBindingSpecDie) DieFeedRawExtension(raw runtime.RawExtension) *S } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingSpecDie) DieRelease() apisv1beta1.ServiceBindingSpec { +func (d *ServiceBindingSpecDie) DieRelease() apisv1.ServiceBindingSpec { if d.mutable { return d.r } @@ -1272,7 +1272,7 @@ func (d *ServiceBindingSpecDie) DieRelease() apisv1beta1.ServiceBindingSpec { } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingSpecDie) DieReleasePtr() *apisv1beta1.ServiceBindingSpec { +func (d *ServiceBindingSpecDie) DieReleasePtr() *apisv1.ServiceBindingSpec { r := d.DieRelease() return &r } @@ -1308,7 +1308,7 @@ func (d *ServiceBindingSpecDie) DieReleaseRawExtension() runtime.RawExtension { } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingSpecDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingSpec)) *ServiceBindingSpecDie { +func (d *ServiceBindingSpecDie) DieStamp(fn func(r *apisv1.ServiceBindingSpec)) *ServiceBindingSpecDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -1318,7 +1318,7 @@ func (d *ServiceBindingSpecDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingSp // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingSpecDie) DieStampAt(jp string, fn interface{}) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -1374,51 +1374,51 @@ func (d *ServiceBindingSpecDie) DeepCopy() *ServiceBindingSpecDie { // Name is the name of the service as projected into the workload container. Defaults to .metadata.name. func (d *ServiceBindingSpecDie) Name(v string) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Name = v }) } // Type is the type of the service as projected into the workload container func (d *ServiceBindingSpecDie) Type(v string) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Type = v }) } // Provider is the provider of the service as projected into the workload container func (d *ServiceBindingSpecDie) Provider(v string) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Provider = v }) } // Workload is a reference to an object -func (d *ServiceBindingSpecDie) Workload(v apisv1beta1.ServiceBindingWorkloadReference) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { +func (d *ServiceBindingSpecDie) Workload(v apisv1.ServiceBindingWorkloadReference) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Workload = v }) } // Service is a reference to an object that fulfills the ProvisionedService duck type -func (d *ServiceBindingSpecDie) Service(v apisv1beta1.ServiceBindingServiceReference) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { +func (d *ServiceBindingSpecDie) Service(v apisv1.ServiceBindingServiceReference) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Service = v }) } // Env is the collection of mappings from Secret entries to environment variables -func (d *ServiceBindingSpecDie) Env(v ...apisv1beta1.EnvMapping) *ServiceBindingSpecDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSpec) { +func (d *ServiceBindingSpecDie) Env(v ...apisv1.EnvMapping) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { r.Env = v }) } -var ServiceBindingWorkloadReferenceBlank = (&ServiceBindingWorkloadReferenceDie{}).DieFeed(apisv1beta1.ServiceBindingWorkloadReference{}) +var ServiceBindingWorkloadReferenceBlank = (&ServiceBindingWorkloadReferenceDie{}).DieFeed(apisv1.ServiceBindingWorkloadReference{}) type ServiceBindingWorkloadReferenceDie struct { mutable bool - r apisv1beta1.ServiceBindingWorkloadReference + r apisv1.ServiceBindingWorkloadReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1432,7 +1432,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieImmutable(immutable bool) *Servi } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingWorkloadReferenceDie) DieFeed(r apisv1beta1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { +func (d *ServiceBindingWorkloadReferenceDie) DieFeed(r apisv1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { if d.mutable { d.r = r return d @@ -1444,16 +1444,16 @@ func (d *ServiceBindingWorkloadReferenceDie) DieFeed(r apisv1beta1.ServiceBindin } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingWorkloadReferenceDie) DieFeedPtr(r *apisv1beta1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { +func (d *ServiceBindingWorkloadReferenceDie) DieFeedPtr(r *apisv1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { if r == nil { - r = &apisv1beta1.ServiceBindingWorkloadReference{} + r = &apisv1.ServiceBindingWorkloadReference{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingWorkloadReferenceDie) DieFeedJSON(j []byte) *ServiceBindingWorkloadReferenceDie { - r := apisv1beta1.ServiceBindingWorkloadReference{} + r := apisv1.ServiceBindingWorkloadReference{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -1462,7 +1462,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieFeedJSON(j []byte) *ServiceBindi // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingWorkloadReferenceDie) DieFeedYAML(y []byte) *ServiceBindingWorkloadReferenceDie { - r := apisv1beta1.ServiceBindingWorkloadReference{} + r := apisv1.ServiceBindingWorkloadReference{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -1488,7 +1488,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieFeedRawExtension(raw runtime.Raw } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingWorkloadReferenceDie) DieRelease() apisv1beta1.ServiceBindingWorkloadReference { +func (d *ServiceBindingWorkloadReferenceDie) DieRelease() apisv1.ServiceBindingWorkloadReference { if d.mutable { return d.r } @@ -1496,7 +1496,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieRelease() apisv1beta1.ServiceBin } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingWorkloadReferenceDie) DieReleasePtr() *apisv1beta1.ServiceBindingWorkloadReference { +func (d *ServiceBindingWorkloadReferenceDie) DieReleasePtr() *apisv1.ServiceBindingWorkloadReference { r := d.DieRelease() return &r } @@ -1532,7 +1532,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieReleaseRawExtension() runtime.Ra } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingWorkloadReferenceDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingWorkloadReference)) *ServiceBindingWorkloadReferenceDie { +func (d *ServiceBindingWorkloadReferenceDie) DieStamp(fn func(r *apisv1.ServiceBindingWorkloadReference)) *ServiceBindingWorkloadReferenceDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -1542,7 +1542,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieStamp(fn func(r *apisv1beta1.Ser // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingWorkloadReferenceDie) DieStampAt(jp string, fn interface{}) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -1598,44 +1598,44 @@ func (d *ServiceBindingWorkloadReferenceDie) DeepCopy() *ServiceBindingWorkloadR // API version of the referent. func (d *ServiceBindingWorkloadReferenceDie) APIVersion(v string) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { r.APIVersion = v }) } // Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds func (d *ServiceBindingWorkloadReferenceDie) Kind(v string) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { r.Kind = v }) } // Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names func (d *ServiceBindingWorkloadReferenceDie) Name(v string) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { r.Name = v }) } // Selector is a query that selects the workload or workloads to bind the service to -func (d *ServiceBindingWorkloadReferenceDie) Selector(v *metav1.LabelSelector) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { +func (d *ServiceBindingWorkloadReferenceDie) Selector(v *apismetav1.LabelSelector) *ServiceBindingWorkloadReferenceDie { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { r.Selector = v }) } // Containers describes which containers in a Pod should be bound to func (d *ServiceBindingWorkloadReferenceDie) Containers(v ...string) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingWorkloadReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { r.Containers = v }) } -var ServiceBindingServiceReferenceBlank = (&ServiceBindingServiceReferenceDie{}).DieFeed(apisv1beta1.ServiceBindingServiceReference{}) +var ServiceBindingServiceReferenceBlank = (&ServiceBindingServiceReferenceDie{}).DieFeed(apisv1.ServiceBindingServiceReference{}) type ServiceBindingServiceReferenceDie struct { mutable bool - r apisv1beta1.ServiceBindingServiceReference + r apisv1.ServiceBindingServiceReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1649,7 +1649,7 @@ func (d *ServiceBindingServiceReferenceDie) DieImmutable(immutable bool) *Servic } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingServiceReferenceDie) DieFeed(r apisv1beta1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { +func (d *ServiceBindingServiceReferenceDie) DieFeed(r apisv1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { if d.mutable { d.r = r return d @@ -1661,16 +1661,16 @@ func (d *ServiceBindingServiceReferenceDie) DieFeed(r apisv1beta1.ServiceBinding } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingServiceReferenceDie) DieFeedPtr(r *apisv1beta1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { +func (d *ServiceBindingServiceReferenceDie) DieFeedPtr(r *apisv1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { if r == nil { - r = &apisv1beta1.ServiceBindingServiceReference{} + r = &apisv1.ServiceBindingServiceReference{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingServiceReferenceDie) DieFeedJSON(j []byte) *ServiceBindingServiceReferenceDie { - r := apisv1beta1.ServiceBindingServiceReference{} + r := apisv1.ServiceBindingServiceReference{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -1679,7 +1679,7 @@ func (d *ServiceBindingServiceReferenceDie) DieFeedJSON(j []byte) *ServiceBindin // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingServiceReferenceDie) DieFeedYAML(y []byte) *ServiceBindingServiceReferenceDie { - r := apisv1beta1.ServiceBindingServiceReference{} + r := apisv1.ServiceBindingServiceReference{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -1705,7 +1705,7 @@ func (d *ServiceBindingServiceReferenceDie) DieFeedRawExtension(raw runtime.RawE } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingServiceReferenceDie) DieRelease() apisv1beta1.ServiceBindingServiceReference { +func (d *ServiceBindingServiceReferenceDie) DieRelease() apisv1.ServiceBindingServiceReference { if d.mutable { return d.r } @@ -1713,7 +1713,7 @@ func (d *ServiceBindingServiceReferenceDie) DieRelease() apisv1beta1.ServiceBind } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingServiceReferenceDie) DieReleasePtr() *apisv1beta1.ServiceBindingServiceReference { +func (d *ServiceBindingServiceReferenceDie) DieReleasePtr() *apisv1.ServiceBindingServiceReference { r := d.DieRelease() return &r } @@ -1749,7 +1749,7 @@ func (d *ServiceBindingServiceReferenceDie) DieReleaseRawExtension() runtime.Raw } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingServiceReferenceDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingServiceReference)) *ServiceBindingServiceReferenceDie { +func (d *ServiceBindingServiceReferenceDie) DieStamp(fn func(r *apisv1.ServiceBindingServiceReference)) *ServiceBindingServiceReferenceDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -1759,7 +1759,7 @@ func (d *ServiceBindingServiceReferenceDie) DieStamp(fn func(r *apisv1beta1.Serv // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingServiceReferenceDie) DieStampAt(jp string, fn interface{}) *ServiceBindingServiceReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingServiceReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingServiceReference) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -1815,30 +1815,30 @@ func (d *ServiceBindingServiceReferenceDie) DeepCopy() *ServiceBindingServiceRef // API version of the referent. func (d *ServiceBindingServiceReferenceDie) APIVersion(v string) *ServiceBindingServiceReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingServiceReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingServiceReference) { r.APIVersion = v }) } // Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds func (d *ServiceBindingServiceReferenceDie) Kind(v string) *ServiceBindingServiceReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingServiceReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingServiceReference) { r.Kind = v }) } // Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names func (d *ServiceBindingServiceReferenceDie) Name(v string) *ServiceBindingServiceReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingServiceReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingServiceReference) { r.Name = v }) } -var EnvMappingBlank = (&EnvMappingDie{}).DieFeed(apisv1beta1.EnvMapping{}) +var EnvMappingBlank = (&EnvMappingDie{}).DieFeed(apisv1.EnvMapping{}) type EnvMappingDie struct { mutable bool - r apisv1beta1.EnvMapping + r apisv1.EnvMapping } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1852,7 +1852,7 @@ func (d *EnvMappingDie) DieImmutable(immutable bool) *EnvMappingDie { } // DieFeed returns a new die with the provided resource. -func (d *EnvMappingDie) DieFeed(r apisv1beta1.EnvMapping) *EnvMappingDie { +func (d *EnvMappingDie) DieFeed(r apisv1.EnvMapping) *EnvMappingDie { if d.mutable { d.r = r return d @@ -1864,16 +1864,16 @@ func (d *EnvMappingDie) DieFeed(r apisv1beta1.EnvMapping) *EnvMappingDie { } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *EnvMappingDie) DieFeedPtr(r *apisv1beta1.EnvMapping) *EnvMappingDie { +func (d *EnvMappingDie) DieFeedPtr(r *apisv1.EnvMapping) *EnvMappingDie { if r == nil { - r = &apisv1beta1.EnvMapping{} + r = &apisv1.EnvMapping{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *EnvMappingDie) DieFeedJSON(j []byte) *EnvMappingDie { - r := apisv1beta1.EnvMapping{} + r := apisv1.EnvMapping{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -1882,7 +1882,7 @@ func (d *EnvMappingDie) DieFeedJSON(j []byte) *EnvMappingDie { // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *EnvMappingDie) DieFeedYAML(y []byte) *EnvMappingDie { - r := apisv1beta1.EnvMapping{} + r := apisv1.EnvMapping{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -1908,7 +1908,7 @@ func (d *EnvMappingDie) DieFeedRawExtension(raw runtime.RawExtension) *EnvMappin } // DieRelease returns the resource managed by the die. -func (d *EnvMappingDie) DieRelease() apisv1beta1.EnvMapping { +func (d *EnvMappingDie) DieRelease() apisv1.EnvMapping { if d.mutable { return d.r } @@ -1916,7 +1916,7 @@ func (d *EnvMappingDie) DieRelease() apisv1beta1.EnvMapping { } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *EnvMappingDie) DieReleasePtr() *apisv1beta1.EnvMapping { +func (d *EnvMappingDie) DieReleasePtr() *apisv1.EnvMapping { r := d.DieRelease() return &r } @@ -1952,7 +1952,7 @@ func (d *EnvMappingDie) DieReleaseRawExtension() runtime.RawExtension { } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *EnvMappingDie) DieStamp(fn func(r *apisv1beta1.EnvMapping)) *EnvMappingDie { +func (d *EnvMappingDie) DieStamp(fn func(r *apisv1.EnvMapping)) *EnvMappingDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -1962,7 +1962,7 @@ func (d *EnvMappingDie) DieStamp(fn func(r *apisv1beta1.EnvMapping)) *EnvMapping // // Future iterations will improve type coercion from the resource to the callback argument. func (d *EnvMappingDie) DieStampAt(jp string, fn interface{}) *EnvMappingDie { - return d.DieStamp(func(r *apisv1beta1.EnvMapping) { + return d.DieStamp(func(r *apisv1.EnvMapping) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -2018,23 +2018,23 @@ func (d *EnvMappingDie) DeepCopy() *EnvMappingDie { // Name is the name of the environment variable func (d *EnvMappingDie) Name(v string) *EnvMappingDie { - return d.DieStamp(func(r *apisv1beta1.EnvMapping) { + return d.DieStamp(func(r *apisv1.EnvMapping) { r.Name = v }) } // Key is the key in the Secret that will be exposed func (d *EnvMappingDie) Key(v string) *EnvMappingDie { - return d.DieStamp(func(r *apisv1beta1.EnvMapping) { + return d.DieStamp(func(r *apisv1.EnvMapping) { r.Key = v }) } -var ServiceBindingStatusBlank = (&ServiceBindingStatusDie{}).DieFeed(apisv1beta1.ServiceBindingStatus{}) +var ServiceBindingStatusBlank = (&ServiceBindingStatusDie{}).DieFeed(apisv1.ServiceBindingStatus{}) type ServiceBindingStatusDie struct { mutable bool - r apisv1beta1.ServiceBindingStatus + r apisv1.ServiceBindingStatus } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -2048,7 +2048,7 @@ func (d *ServiceBindingStatusDie) DieImmutable(immutable bool) *ServiceBindingSt } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingStatusDie) DieFeed(r apisv1beta1.ServiceBindingStatus) *ServiceBindingStatusDie { +func (d *ServiceBindingStatusDie) DieFeed(r apisv1.ServiceBindingStatus) *ServiceBindingStatusDie { if d.mutable { d.r = r return d @@ -2060,16 +2060,16 @@ func (d *ServiceBindingStatusDie) DieFeed(r apisv1beta1.ServiceBindingStatus) *S } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingStatusDie) DieFeedPtr(r *apisv1beta1.ServiceBindingStatus) *ServiceBindingStatusDie { +func (d *ServiceBindingStatusDie) DieFeedPtr(r *apisv1.ServiceBindingStatus) *ServiceBindingStatusDie { if r == nil { - r = &apisv1beta1.ServiceBindingStatus{} + r = &apisv1.ServiceBindingStatus{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingStatusDie) DieFeedJSON(j []byte) *ServiceBindingStatusDie { - r := apisv1beta1.ServiceBindingStatus{} + r := apisv1.ServiceBindingStatus{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -2078,7 +2078,7 @@ func (d *ServiceBindingStatusDie) DieFeedJSON(j []byte) *ServiceBindingStatusDie // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingStatusDie) DieFeedYAML(y []byte) *ServiceBindingStatusDie { - r := apisv1beta1.ServiceBindingStatus{} + r := apisv1.ServiceBindingStatus{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -2104,7 +2104,7 @@ func (d *ServiceBindingStatusDie) DieFeedRawExtension(raw runtime.RawExtension) } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingStatusDie) DieRelease() apisv1beta1.ServiceBindingStatus { +func (d *ServiceBindingStatusDie) DieRelease() apisv1.ServiceBindingStatus { if d.mutable { return d.r } @@ -2112,7 +2112,7 @@ func (d *ServiceBindingStatusDie) DieRelease() apisv1beta1.ServiceBindingStatus } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingStatusDie) DieReleasePtr() *apisv1beta1.ServiceBindingStatus { +func (d *ServiceBindingStatusDie) DieReleasePtr() *apisv1.ServiceBindingStatus { r := d.DieRelease() return &r } @@ -2148,7 +2148,7 @@ func (d *ServiceBindingStatusDie) DieReleaseRawExtension() runtime.RawExtension } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingStatusDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingStatus)) *ServiceBindingStatusDie { +func (d *ServiceBindingStatusDie) DieStamp(fn func(r *apisv1.ServiceBindingStatus)) *ServiceBindingStatusDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -2158,7 +2158,7 @@ func (d *ServiceBindingStatusDie) DieStamp(fn func(r *apisv1beta1.ServiceBinding // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingStatusDie) DieStampAt(jp string, fn interface{}) *ServiceBindingStatusDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingStatus) { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -2214,30 +2214,30 @@ func (d *ServiceBindingStatusDie) DeepCopy() *ServiceBindingStatusDie { // ObservedGeneration is the 'Generation' of the ServiceBinding that was last processed by the controller. func (d *ServiceBindingStatusDie) ObservedGeneration(v int64) *ServiceBindingStatusDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingStatus) { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { r.ObservedGeneration = v }) } // Conditions are the conditions of this ServiceBinding -func (d *ServiceBindingStatusDie) Conditions(v ...metav1.Condition) *ServiceBindingStatusDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingStatus) { +func (d *ServiceBindingStatusDie) Conditions(v ...apismetav1.Condition) *ServiceBindingStatusDie { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { r.Conditions = v }) } // Binding exposes the projected secret for this ServiceBinding -func (d *ServiceBindingStatusDie) Binding(v *apisv1beta1.ServiceBindingSecretReference) *ServiceBindingStatusDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingStatus) { +func (d *ServiceBindingStatusDie) Binding(v *apisv1.ServiceBindingSecretReference) *ServiceBindingStatusDie { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { r.Binding = v }) } -var ServiceBindingSecretReferenceBlank = (&ServiceBindingSecretReferenceDie{}).DieFeed(apisv1beta1.ServiceBindingSecretReference{}) +var ServiceBindingSecretReferenceBlank = (&ServiceBindingSecretReferenceDie{}).DieFeed(apisv1.ServiceBindingSecretReference{}) type ServiceBindingSecretReferenceDie struct { mutable bool - r apisv1beta1.ServiceBindingSecretReference + r apisv1.ServiceBindingSecretReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -2251,7 +2251,7 @@ func (d *ServiceBindingSecretReferenceDie) DieImmutable(immutable bool) *Service } // DieFeed returns a new die with the provided resource. -func (d *ServiceBindingSecretReferenceDie) DieFeed(r apisv1beta1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { +func (d *ServiceBindingSecretReferenceDie) DieFeed(r apisv1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { if d.mutable { d.r = r return d @@ -2263,16 +2263,16 @@ func (d *ServiceBindingSecretReferenceDie) DieFeed(r apisv1beta1.ServiceBindingS } // DieFeedPtr returns a new die with the provided resource pointer. If the resource is nil, the empty value is used instead. -func (d *ServiceBindingSecretReferenceDie) DieFeedPtr(r *apisv1beta1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { +func (d *ServiceBindingSecretReferenceDie) DieFeedPtr(r *apisv1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { if r == nil { - r = &apisv1beta1.ServiceBindingSecretReference{} + r = &apisv1.ServiceBindingSecretReference{} } return d.DieFeed(*r) } // DieFeedJSON returns a new die with the provided JSON. Panics on error. func (d *ServiceBindingSecretReferenceDie) DieFeedJSON(j []byte) *ServiceBindingSecretReferenceDie { - r := apisv1beta1.ServiceBindingSecretReference{} + r := apisv1.ServiceBindingSecretReference{} if err := json.Unmarshal(j, &r); err != nil { panic(err) } @@ -2281,7 +2281,7 @@ func (d *ServiceBindingSecretReferenceDie) DieFeedJSON(j []byte) *ServiceBinding // DieFeedYAML returns a new die with the provided YAML. Panics on error. func (d *ServiceBindingSecretReferenceDie) DieFeedYAML(y []byte) *ServiceBindingSecretReferenceDie { - r := apisv1beta1.ServiceBindingSecretReference{} + r := apisv1.ServiceBindingSecretReference{} if err := yaml.Unmarshal(y, &r); err != nil { panic(err) } @@ -2307,7 +2307,7 @@ func (d *ServiceBindingSecretReferenceDie) DieFeedRawExtension(raw runtime.RawEx } // DieRelease returns the resource managed by the die. -func (d *ServiceBindingSecretReferenceDie) DieRelease() apisv1beta1.ServiceBindingSecretReference { +func (d *ServiceBindingSecretReferenceDie) DieRelease() apisv1.ServiceBindingSecretReference { if d.mutable { return d.r } @@ -2315,7 +2315,7 @@ func (d *ServiceBindingSecretReferenceDie) DieRelease() apisv1beta1.ServiceBindi } // DieReleasePtr returns a pointer to the resource managed by the die. -func (d *ServiceBindingSecretReferenceDie) DieReleasePtr() *apisv1beta1.ServiceBindingSecretReference { +func (d *ServiceBindingSecretReferenceDie) DieReleasePtr() *apisv1.ServiceBindingSecretReference { r := d.DieRelease() return &r } @@ -2351,7 +2351,7 @@ func (d *ServiceBindingSecretReferenceDie) DieReleaseRawExtension() runtime.RawE } // DieStamp returns a new die with the resource passed to the callback function. The resource is mutable. -func (d *ServiceBindingSecretReferenceDie) DieStamp(fn func(r *apisv1beta1.ServiceBindingSecretReference)) *ServiceBindingSecretReferenceDie { +func (d *ServiceBindingSecretReferenceDie) DieStamp(fn func(r *apisv1.ServiceBindingSecretReference)) *ServiceBindingSecretReferenceDie { r := d.DieRelease() fn(&r) return d.DieFeed(r) @@ -2361,7 +2361,7 @@ func (d *ServiceBindingSecretReferenceDie) DieStamp(fn func(r *apisv1beta1.Servi // // Future iterations will improve type coercion from the resource to the callback argument. func (d *ServiceBindingSecretReferenceDie) DieStampAt(jp string, fn interface{}) *ServiceBindingSecretReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSecretReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingSecretReference) { if ni := reflectx.ValueOf(fn).Type().NumIn(); ni != 1 { panic(fmtx.Errorf("callback function must have 1 input parameters, found %d", ni)) } @@ -2417,7 +2417,7 @@ func (d *ServiceBindingSecretReferenceDie) DeepCopy() *ServiceBindingSecretRefer // Name of the referent secret. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names func (d *ServiceBindingSecretReferenceDie) Name(v string) *ServiceBindingSecretReferenceDie { - return d.DieStamp(func(r *apisv1beta1.ServiceBindingSecretReference) { + return d.DieStamp(func(r *apisv1.ServiceBindingSecretReference) { r.Name = v }) } diff --git a/dies/v1beta1/zz_generated.die_test.go b/dies/v1/zz_generated.die_test.go similarity index 99% rename from dies/v1beta1/zz_generated.die_test.go rename to dies/v1/zz_generated.die_test.go index bfc18cc5..460405e4 100644 --- a/dies/v1beta1/zz_generated.die_test.go +++ b/dies/v1/zz_generated.die_test.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by diegen. DO NOT EDIT. -package v1beta1 +package v1 import ( testingx "testing" diff --git a/dies/v1beta1/clusterworkloadresourcemapping.go b/dies/v1beta1/clusterworkloadresourcemapping.go index a31ab595..18cc1bbb 100644 --- a/dies/v1beta1/clusterworkloadresourcemapping.go +++ b/dies/v1beta1/clusterworkloadresourcemapping.go @@ -17,43 +17,21 @@ limitations under the License. package v1beta1 import ( - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" ) -// +die:object=true -type _ = servicebindingv1beta1.ClusterWorkloadResourceMapping - -// +die -type _ = servicebindingv1beta1.ClusterWorkloadResourceMappingSpec - -func (d *ClusterWorkloadResourceMappingSpecDie) VersionsDie(version string, fn func(d *ClusterWorkloadResourceMappingTemplateDie)) *ClusterWorkloadResourceMappingSpecDie { - return d.DieStamp(func(r *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec) { - for i := range r.Versions { - if version == r.Versions[i].Version { - d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(r.Versions[i]) - fn(d) - r.Versions[i] = d.DieRelease() - return - } - } - - d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{Version: version}) - fn(d) - r.Versions = append(r.Versions, d.DieRelease()) - }) -} - -// +die -type _ = servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate - -func (d *ClusterWorkloadResourceMappingTemplateDie) ContainersDie(containers ...*ClusterWorkloadResourceMappingContainerDie) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate) { - r.Containers = make([]servicebindingv1beta1.ClusterWorkloadResourceMappingContainer, len(containers)) - for i := range containers { - r.Containers[i] = containers[i].DieRelease() - } - }) -} - -// +die -type _ = servicebindingv1beta1.ClusterWorkloadResourceMappingContainer +var ClusterWorkloadResourceMappingBlank = dieservicebindingv1.ClusterWorkloadResourceMappingBlank + +type ClusterWorkloadResourceMappingDie = dieservicebindingv1.ClusterWorkloadResourceMappingDie + +var ClusterWorkloadResourceMappingSpecBlank = dieservicebindingv1.ClusterWorkloadResourceMappingSpecBlank + +type ClusterWorkloadResourceMappingSpecDie = dieservicebindingv1.ClusterWorkloadResourceMappingSpecDie + +var ClusterWorkloadResourceMappingTemplateBlank = dieservicebindingv1.ClusterWorkloadResourceMappingTemplateBlank + +type ClusterWorkloadResourceMappingTemplateDie = dieservicebindingv1.ClusterWorkloadResourceMappingTemplateDie + +var ClusterWorkloadResourceMappingContainerBlank = dieservicebindingv1.ClusterWorkloadResourceMappingContainerBlank + +type ClusterWorkloadResourceMappingContainerDie = dieservicebindingv1.ClusterWorkloadResourceMappingContainerDie diff --git a/dies/v1beta1/servicebinding.go b/dies/v1beta1/servicebinding.go index ec71c7fb..86ae3010 100644 --- a/dies/v1beta1/servicebinding.go +++ b/dies/v1beta1/servicebinding.go @@ -17,91 +17,37 @@ limitations under the License. package v1beta1 import ( - diemetav1 "dies.dev/apis/meta/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" ) -// +die:object=true -type _ = servicebindingv1beta1.ServiceBinding - -// +die -type _ = servicebindingv1beta1.ServiceBindingSpec - -func (d *ServiceBindingSpecDie) WorkloadDie(fn func(d *ServiceBindingWorkloadReferenceDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingSpec) { - d := ServiceBindingWorkloadReferenceBlank.DieImmutable(false).DieFeed(r.Workload) - fn(d) - r.Workload = d.DieRelease() - }) -} - -func (d *ServiceBindingSpecDie) ServiceDie(fn func(d *ServiceBindingServiceReferenceDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingSpec) { - d := ServiceBindingServiceReferenceBlank.DieImmutable(false).DieFeed(r.Service) - fn(d) - r.Service = d.DieRelease() - }) -} - -func (d *ServiceBindingSpecDie) EnvDie(name string, fn func(d *EnvMappingDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingSpec) { - for i := range r.Env { - if name == r.Env[i].Name { - d := EnvMappingBlank.DieImmutable(false).DieFeed(r.Env[i]) - fn(d) - r.Env[i] = d.DieRelease() - return - } - } - - d := EnvMappingBlank.DieImmutable(false).DieFeed(servicebindingv1beta1.EnvMapping{Name: name}) - fn(d) - r.Env = append(r.Env, d.DieRelease()) - }) -} - -// +die -type _ = servicebindingv1beta1.ServiceBindingWorkloadReference - -func (d *ServiceBindingWorkloadReferenceDie) SelectorDie(fn func(d *diemetav1.LabelSelectorDie)) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingWorkloadReference) { - d := diemetav1.LabelSelectorBlank.DieImmutable(false).DieFeedPtr(r.Selector) - fn(d) - r.Selector = d.DieReleasePtr() - }) -} - -// +die -type _ = servicebindingv1beta1.ServiceBindingServiceReference - -// +die -type _ = servicebindingv1beta1.EnvMapping - -// +die -type _ = servicebindingv1beta1.ServiceBindingStatus - -func (d *ServiceBindingStatusDie) ConditionsDie(conditions ...*diemetav1.ConditionDie) *ServiceBindingStatusDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingStatus) { - r.Conditions = make([]metav1.Condition, len(conditions)) - for i := range conditions { - r.Conditions[i] = conditions[i].DieRelease() - } - }) -} - -var ServiceBindingConditionReady = diemetav1.ConditionBlank.Type(servicebindingv1beta1.ServiceBindingConditionReady).Unknown().Reason("Initializing") -var ServiceBindingConditionServiceAvailable = diemetav1.ConditionBlank.Type(servicebindingv1beta1.ServiceBindingConditionServiceAvailable).Unknown().Reason("Initializing") -var ServiceBindingConditionWorkloadProjected = diemetav1.ConditionBlank.Type(servicebindingv1beta1.ServiceBindingConditionWorkloadProjected).Unknown().Reason("Initializing") - -func (d *ServiceBindingStatusDie) BindingDie(fn func(d *ServiceBindingSecretReferenceDie)) *ServiceBindingStatusDie { - return d.DieStamp(func(r *servicebindingv1beta1.ServiceBindingStatus) { - d := ServiceBindingSecretReferenceBlank.DieImmutable(false).DieFeedPtr(r.Binding) - fn(d) - r.Binding = d.DieReleasePtr() - }) -} - -// +die -type _ = servicebindingv1beta1.ServiceBindingSecretReference +var ServiceBindingBlank = dieservicebindingv1.ServiceBindingBlank + +type ServiceBindingDie = dieservicebindingv1.ServiceBindingDie + +var ServiceBindingSpecBlank = dieservicebindingv1.ServiceBindingSpecBlank + +type ServiceBindingSpecDie = dieservicebindingv1.ServiceBindingSpecDie + +var ServiceBindingWorkloadReferenceBlank = dieservicebindingv1.ServiceBindingWorkloadReferenceBlank + +type ServiceBindingWorkloadReferenceDie = dieservicebindingv1.ServiceBindingWorkloadReferenceDie + +var ServiceBindingServiceReferenceBlank = dieservicebindingv1.ServiceBindingServiceReferenceBlank + +type ServiceBindingServiceReferenceDie = dieservicebindingv1.ServiceBindingServiceReferenceDie + +var EnvMappingBlank = dieservicebindingv1.EnvMappingBlank + +type EnvMappingDie = dieservicebindingv1.EnvMappingDie + +var ServiceBindingStatusBlank = dieservicebindingv1.ServiceBindingStatusBlank + +type ServiceBindingStatusDie = dieservicebindingv1.ServiceBindingStatusDie + +var ServiceBindingConditionReady = dieservicebindingv1.ServiceBindingConditionReady +var ServiceBindingConditionServiceAvailable = dieservicebindingv1.ServiceBindingConditionServiceAvailable +var ServiceBindingConditionWorkloadProjected = dieservicebindingv1.ServiceBindingConditionWorkloadProjected + +var ServiceBindingSecretReferenceBlank = dieservicebindingv1.ServiceBindingSecretReferenceBlank + +type ServiceBindingSecretReferenceDie = dieservicebindingv1.ServiceBindingSecretReferenceDie diff --git a/lifecycle/hooks.go b/lifecycle/hooks.go index 17d966fa..191205f1 100644 --- a/lifecycle/hooks.go +++ b/lifecycle/hooks.go @@ -22,7 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/projector" "github.com/servicebinding/runtime/resolver" ) @@ -44,13 +44,13 @@ type ServiceBindingHooks struct { // ServiceBinding before the projection. // // +optional - ServiceBindingPreProjection func(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error + ServiceBindingPreProjection func(ctx context.Context, binding *servicebindingv1.ServiceBinding) error // ServiceBindingPostProjection can be used to alter the projected // ServiceBinding before mutations are persisted. // // +optional - ServiceBindingPostProjection func(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error + ServiceBindingPostProjection func(ctx context.Context, binding *servicebindingv1.ServiceBinding) error // WorkloadPreProjection can be used to alter the resolved workload before // the projection. diff --git a/lifecycle/hooks_test.go b/lifecycle/hooks_test.go index 2dfa64fe..be5a7789 100644 --- a/lifecycle/hooks_test.go +++ b/lifecycle/hooks_test.go @@ -42,9 +42,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/controllers" - dieservicebindingv1beta1 "github.com/servicebinding/runtime/dies/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" "github.com/servicebinding/runtime/lifecycle" "github.com/servicebinding/runtime/projector" "github.com/servicebinding/runtime/resolver" @@ -57,43 +57,43 @@ func TestServiceBindingHooks(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.Finalizers("servicebinding.io/finalizer") d.UID(uuid.NewUUID()) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("v1") d.Kind("Secret") d.Name(secretName) }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("ResolvedBindingSecret"), ) }) serviceBindingByName := serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name(name) }) }) serviceBindingBySelector := serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.SelectorDie(func(d *diemetav1.LabelSelectorDie) { @@ -149,7 +149,7 @@ func TestServiceBindingHooks(t *testing.T) { d.AddLabel("test.servicebinding.io", "workload") }) - rts := rtesting.SubReconcilerTests[*servicebindingv1beta1.ServiceBinding]{ + rts := rtesting.SubReconcilerTests[*servicebindingv1.ServiceBinding]{ "controller binding by name": { Metadata: map[string]interface{}{ "HooksExpectations": func(m *mock.Mock) { @@ -160,7 +160,7 @@ func TestServiceBindingHooks(t *testing.T) { m.On("ServiceBindingPostProjection", 5, anyContext, matchObj(serviceBinding.DieReleasePtr())).Return(nil).Once() }, }, - CleanUp: func(t *testing.T, ctx context.Context, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding]) error { + CleanUp: func(t *testing.T, ctx context.Context, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding]) error { m := tc.Metadata["HooksMock"].(*mock.Mock) m.AssertExpectations(t) return nil @@ -186,7 +186,7 @@ func TestServiceBindingHooks(t *testing.T) { m.On("ServiceBindingPostProjection", 8, anyContext, matchObj(serviceBinding.DieReleasePtr())).Return(nil).Once() }, }, - CleanUp: func(t *testing.T, ctx context.Context, tc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding]) error { + CleanUp: func(t *testing.T, ctx context.Context, tc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding]) error { m := tc.Metadata["HooksMock"].(*mock.Mock) m.AssertExpectations(t) return nil @@ -212,7 +212,7 @@ func TestServiceBindingHooks(t *testing.T) { }, } - rts.Run(t, scheme, func(t *testing.T, rtc *rtesting.SubReconcilerTestCase[*servicebindingv1beta1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1beta1.ServiceBinding] { + rts.Run(t, scheme, func(t *testing.T, rtc *rtesting.SubReconcilerTestCase[*servicebindingv1.ServiceBinding], c reconcilers.Config) reconcilers.SubReconciler[*servicebindingv1.ServiceBinding] { restMapper := c.RESTMapper().(*meta.DefaultRESTMapper) restMapper.Add(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}, meta.RESTScopeNamespace) hooks, m := makeHooks() @@ -235,7 +235,7 @@ func TestServiceBindingHooks(t *testing.T) { }) addWorkloadRefIndex := func(cb *fake.ClientBuilder) *fake.ClientBuilder { - return cb.WithIndex(&servicebindingv1beta1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) + return cb.WithIndex(&servicebindingv1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) } rts := rtesting.SubReconcilerTests[*unstructured.Unstructured]{ @@ -282,17 +282,17 @@ type mockProjector struct { i *int } -func (p *mockProjector) Project(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error { +func (p *mockProjector) Project(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error { *p.i = *p.i + 1 return p.m.MethodCalled("Projector.Project", *p.i, ctx, binding, workload).Error(0) } -func (p *mockProjector) Unproject(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error { +func (p *mockProjector) Unproject(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error { *p.i = *p.i + 1 return p.m.MethodCalled("Projector.Unproject", *p.i, ctx, binding, workload).Error(0) } -func (p *mockProjector) IsProjected(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) bool { +func (p *mockProjector) IsProjected(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) bool { annotations := workload.(metav1.Object).GetAnnotations() if len(annotations) == 0 { return false @@ -311,11 +311,11 @@ func makeHooks() (lifecycle.ServiceBindingHooks, *mock.Mock) { ProjectorFactory: func(ms projector.MappingSource) projector.ServiceBindingProjector { return &mockProjector{m: m, i: i} }, - ServiceBindingPreProjection: func(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error { + ServiceBindingPreProjection: func(ctx context.Context, binding *servicebindingv1.ServiceBinding) error { *i = *i + 1 return m.MethodCalled("ServiceBindingPreProjection", *i, ctx, binding).Error(0) }, - ServiceBindingPostProjection: func(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error { + ServiceBindingPostProjection: func(ctx context.Context, binding *servicebindingv1.ServiceBinding) error { *i = *i + 1 return m.MethodCalled("ServiceBindingPostProjection", *i, ctx, binding).Error(0) }, diff --git a/lifecycle/vmware/migration.go b/lifecycle/vmware/migration.go index 3847e52b..2ae2ba25 100644 --- a/lifecycle/vmware/migration.go +++ b/lifecycle/vmware/migration.go @@ -34,13 +34,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/servicebinding/runtime/apis/duck" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/lifecycle" ) func InstallMigrationHooks(hooks lifecycle.ServiceBindingHooks) lifecycle.ServiceBindingHooks { serviceBindingPostProjection := hooks.ServiceBindingPostProjection - hooks.ServiceBindingPostProjection = func(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error { + hooks.ServiceBindingPostProjection = func(ctx context.Context, binding *servicebindingv1.ServiceBinding) error { if err := CleanupServiceBinding(ctx, binding); err != nil { return err } @@ -64,7 +64,7 @@ func InstallMigrationHooks(hooks lifecycle.ServiceBindingHooks) lifecycle.Servic return hooks } -func CleanupServiceBinding(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding) error { +func CleanupServiceBinding(ctx context.Context, binding *servicebindingv1.ServiceBinding) error { if reconcilers.RetrieveRequest(ctx).Name == "" { // we're not in a reconciler return nil diff --git a/lifecycle/vmware/migration_test.go b/lifecycle/vmware/migration_test.go index a7f52c1d..598befd1 100644 --- a/lifecycle/vmware/migration_test.go +++ b/lifecycle/vmware/migration_test.go @@ -44,9 +44,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/controllers" - dieservicebindingv1beta1 "github.com/servicebinding/runtime/dies/v1beta1" + dieservicebindingv1 "github.com/servicebinding/runtime/dies/v1" "github.com/servicebinding/runtime/lifecycle" "github.com/servicebinding/runtime/lifecycle/vmware" ) @@ -62,30 +62,30 @@ func TestMigrationHooks_Controller(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) now := metav1.Now().Rfc3339Copy() - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.UID(uid) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("v1") d.Kind("Secret") d.Name(secretName) }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") }) }) - workloadMapping := dieservicebindingv1beta1.ClusterWorkloadResourceMappingBlank. + workloadMapping := dieservicebindingv1.ClusterWorkloadResourceMappingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Name("deployments.apps") }) @@ -213,20 +213,20 @@ func TestMigrationHooks_Controller(t *testing.T) { "in sync": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -240,17 +240,17 @@ func TestMigrationHooks_Controller(t *testing.T) { "migrate vmware binding": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( diemetav1.ConditionBlank.Type("Ready").True().Reason("Ready").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ServiceAvailable").True().Reason("Available").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ProjectionReady").True().Reason("Projected").LastTransitionTime(now), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -282,13 +282,13 @@ func TestMigrationHooks_Controller(t *testing.T) { MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -297,30 +297,30 @@ func TestMigrationHooks_Controller(t *testing.T) { "migrate vmware binding with projected envvars and overridden type and provider": { Request: request, StatusSubResourceTypes: []client.Object{ - &servicebindingv1beta1.ServiceBinding{}, + &servicebindingv1.ServiceBinding{}, }, GivenObjects: []client.Object{ serviceBinding. - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { d.Type("overridden-type") d.Provider("overridden-provider") - d.EnvDie("BOUND_PASSWORD", func(d *dieservicebindingv1beta1.EnvMappingDie) { + d.EnvDie("BOUND_PASSWORD", func(d *dieservicebindingv1.EnvMappingDie) { d.Key("password") }) - d.EnvDie("BOUND_TYPE", func(d *dieservicebindingv1beta1.EnvMappingDie) { + d.EnvDie("BOUND_TYPE", func(d *dieservicebindingv1.EnvMappingDie) { d.Key("type") }) - d.EnvDie("BOUND_PROVIDER", func(d *dieservicebindingv1beta1.EnvMappingDie) { + d.EnvDie("BOUND_PROVIDER", func(d *dieservicebindingv1.EnvMappingDie) { d.Key("provider") }) }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( diemetav1.ConditionBlank.Type("Ready").True().Reason("Ready").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ServiceAvailable").True().Reason("Available").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ProjectionReady").True().Reason("Projected").LastTransitionTime(now), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -491,13 +491,13 @@ func TestMigrationHooks_Controller(t *testing.T) { MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Finalizers("servicebinding.io/finalizer") }). - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( - dieservicebindingv1beta1.ServiceBindingConditionReady.True().Reason("ServiceBound"), - dieservicebindingv1beta1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), - dieservicebindingv1beta1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), + dieservicebindingv1.ServiceBindingConditionReady.True().Reason("ServiceBound"), + dieservicebindingv1.ServiceBindingConditionServiceAvailable.True().Reason("ResolvedBindingSecret"), + dieservicebindingv1.ServiceBindingConditionWorkloadProjected.True().Reason("WorkloadProjected"), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -525,23 +525,23 @@ func TestMigrationHooks_Webhook(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) now := metav1.Now().Rfc3339Copy() - serviceBinding := dieservicebindingv1beta1.ServiceBindingBlank. + serviceBinding := dieservicebindingv1.ServiceBindingBlank. MetadataDie(func(d *diemetav1.ObjectMetaDie) { d.Namespace(namespace) d.Name(name) d.UID(uid) }). - SpecDie(func(d *dieservicebindingv1beta1.ServiceBindingSpecDie) { - d.ServiceDie(func(d *dieservicebindingv1beta1.ServiceBindingServiceReferenceDie) { + SpecDie(func(d *dieservicebindingv1.ServiceBindingSpecDie) { + d.ServiceDie(func(d *dieservicebindingv1.ServiceBindingServiceReferenceDie) { d.APIVersion("v1") d.Kind("Secret") d.Name(secretName) }) - d.WorkloadDie(func(d *dieservicebindingv1beta1.ServiceBindingWorkloadReferenceDie) { + d.WorkloadDie(func(d *dieservicebindingv1.ServiceBindingWorkloadReferenceDie) { d.APIVersion("apps/v1") d.Kind("Deployment") d.Name("my-workload") @@ -674,7 +674,7 @@ func TestMigrationHooks_Webhook(t *testing.T) { Allowed(true) addWorkloadRefIndex := func(cb *fake.ClientBuilder) *fake.ClientBuilder { - return cb.WithIndex(&servicebindingv1beta1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) + return cb.WithIndex(&servicebindingv1.ServiceBinding{}, controllers.WorkloadRefIndexKey, controllers.WorkloadRefIndexFunc) } rts := rtesting.AdmissionWebhookTests{ @@ -687,13 +687,13 @@ func TestMigrationHooks_Webhook(t *testing.T) { }, GivenObjects: []client.Object{ serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( diemetav1.ConditionBlank.Type("Ready").True().Reason("Ready").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ServiceAvailable").True().Reason("Available").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ProjectionReady").True().Reason("Projected").LastTransitionTime(now), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), @@ -711,13 +711,13 @@ func TestMigrationHooks_Webhook(t *testing.T) { }, GivenObjects: []client.Object{ serviceBinding. - StatusDie(func(d *dieservicebindingv1beta1.ServiceBindingStatusDie) { + StatusDie(func(d *dieservicebindingv1.ServiceBindingStatusDie) { d.ConditionsDie( diemetav1.ConditionBlank.Type("Ready").True().Reason("Ready").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ServiceAvailable").True().Reason("Available").LastTransitionTime(now), diemetav1.ConditionBlank.Type("ProjectionReady").True().Reason("Projected").LastTransitionTime(now), ) - d.BindingDie(func(d *dieservicebindingv1beta1.ServiceBindingSecretReferenceDie) { + d.BindingDie(func(d *dieservicebindingv1.ServiceBindingSecretReferenceDie) { d.Name(secretName) }) }), diff --git a/main.go b/main.go index a162cc6a..a8c727ad 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" servicebindingv1alpha3 "github.com/servicebinding/runtime/apis/v1alpha3" servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" "github.com/servicebinding/runtime/controllers" @@ -57,6 +58,7 @@ func init() { utilruntime.Must(servicebindingv1alpha3.AddToScheme(scheme)) utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -116,7 +118,7 @@ func main() { } ctx := ctrl.SetupSignalHandler() - config := reconcilers.NewConfig(mgr, &servicebindingv1beta1.ServiceBinding{}, syncPeriod) + config := reconcilers.NewConfig(mgr, &servicebindingv1.ServiceBinding{}, syncPeriod) accessChecker := rbac.NewAccessChecker(config, 5*time.Minute) hooks := lifecycle.ServiceBindingHooks{} @@ -135,6 +137,10 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "ServiceBinding") os.Exit(1) } + if err = (&servicebindingv1.ServiceBinding{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "ServiceBinding v1") + os.Exit(1) + } if err = (&servicebindingv1beta1.ServiceBinding{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "ServiceBinding v1beta1") os.Exit(1) @@ -143,6 +149,10 @@ func main() { setupLog.Error(err, "unable to create webhook", "webhook", "ServiceBinding v1alpha3") os.Exit(1) } + if err = (&servicebindingv1.ClusterWorkloadResourceMapping{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "ClusterWorkloadResourceMapping v1") + os.Exit(1) + } if err = (&servicebindingv1beta1.ClusterWorkloadResourceMapping{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "ClusterWorkloadResourceMapping v1beta1") os.Exit(1) diff --git a/projector/binding.go b/projector/binding.go index 4e2246e5..eaf29f12 100644 --- a/projector/binding.go +++ b/projector/binding.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/sets" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) const ( @@ -58,7 +58,7 @@ func New(mappingSource MappingSource) ServiceBindingProjector { } } -func (p *serviceBindingProjector) Project(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error { +func (p *serviceBindingProjector) Project(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error { ctx, resourceMapping, version, err := p.lookupClusterMapping(ctx, workload) if err != nil { return err @@ -92,7 +92,7 @@ func (p *serviceBindingProjector) Project(ctx context.Context, binding *serviceb return nil } -func (p *serviceBindingProjector) Unproject(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error { +func (p *serviceBindingProjector) Unproject(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error { resourceMapping, err := p.retrieveLocalMapping(binding, workload) if err != nil { return err @@ -122,7 +122,7 @@ func (p *serviceBindingProjector) Unproject(ctx context.Context, binding *servic return nil } -func (p *serviceBindingProjector) IsProjected(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) bool { +func (p *serviceBindingProjector) IsProjected(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) bool { annotations := workload.(metav1.Object).GetAnnotations() if len(annotations) == 0 { return false @@ -132,7 +132,7 @@ func (p *serviceBindingProjector) IsProjected(ctx context.Context, binding *serv } type mappingValue struct { - WorkloadMapping *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec + WorkloadMapping *servicebindingv1.ClusterWorkloadResourceMappingSpec RESTMapping *meta.RESTMapping } @@ -140,7 +140,7 @@ type mappingValue struct { // avoids redundant calls to the mappingSource for the same workload call when Unproject // is called from Project. When the lookup is from the cluster, the value is stashed into // the context for future lookups in this turn. -func (p *serviceBindingProjector) lookupClusterMapping(ctx context.Context, workload runtime.Object) (context.Context, *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, string, error) { +func (p *serviceBindingProjector) lookupClusterMapping(ctx context.Context, workload runtime.Object) (context.Context, *servicebindingv1.ClusterWorkloadResourceMappingSpec, string, error) { raw := ctx.Value(mappingValue{}) if value, ok := raw.(mappingValue); ok { return ctx, value.WorkloadMapping, value.RESTMapping.Resource.Version, nil @@ -160,7 +160,7 @@ func (p *serviceBindingProjector) lookupClusterMapping(ctx context.Context, work return ctx, wm, rm.Resource.Version, nil } -func (p *serviceBindingProjector) shouldProject(binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) bool { +func (p *serviceBindingProjector) shouldProject(binding *servicebindingv1.ServiceBinding, workload runtime.Object) bool { if p.secretName(binding) == "" { // no secret to bind return false @@ -181,14 +181,14 @@ func (p *serviceBindingProjector) shouldProject(binding *servicebindingv1beta1.S return false } -func (p *serviceBindingProjector) project(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) { +func (p *serviceBindingProjector) project(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) { p.projectVolume(binding, mpt) for i := range mpt.Containers { p.projectContainer(binding, mpt, &mpt.Containers[i]) } } -func (p *serviceBindingProjector) unproject(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) { +func (p *serviceBindingProjector) unproject(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) { p.unprojectVolume(binding, mpt) for i := range mpt.Containers { p.unprojectContainer(binding, mpt, &mpt.Containers[i]) @@ -200,7 +200,7 @@ func (p *serviceBindingProjector) unproject(binding *servicebindingv1beta1.Servi delete(mpt.PodTemplateAnnotations, p.providerAnnotationName(binding)) } -func (p *serviceBindingProjector) projectVolume(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) { +func (p *serviceBindingProjector) projectVolume(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) { volume := corev1.Volume{ Name: p.volumeName(binding), VolumeSource: corev1.VolumeSource{ @@ -271,7 +271,7 @@ func (p *serviceBindingProjector) projectVolume(binding *servicebindingv1beta1.S }) } -func (p *serviceBindingProjector) unprojectVolume(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) { +func (p *serviceBindingProjector) unprojectVolume(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) { volumes := []corev1.Volume{} projected := p.volumeName(binding) for _, v := range mpt.Volumes { @@ -282,7 +282,7 @@ func (p *serviceBindingProjector) unprojectVolume(binding *servicebindingv1beta1 mpt.Volumes = volumes } -func (p *serviceBindingProjector) projectContainer(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { +func (p *serviceBindingProjector) projectContainer(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { if !p.isContainerBindable(binding, mc) { return } @@ -290,12 +290,12 @@ func (p *serviceBindingProjector) projectContainer(binding *servicebindingv1beta p.projectEnv(binding, mpt, mc) } -func (p *serviceBindingProjector) unprojectContainer(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { +func (p *serviceBindingProjector) unprojectContainer(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { p.unprojectVolumeMount(binding, mc) p.unprojectEnv(binding, mpt, mc) } -func (p *serviceBindingProjector) projectVolumeMount(binding *servicebindingv1beta1.ServiceBinding, mc *metaContainer) { +func (p *serviceBindingProjector) projectVolumeMount(binding *servicebindingv1.ServiceBinding, mc *metaContainer) { mc.VolumeMounts = append(mc.VolumeMounts, corev1.VolumeMount{ Name: p.volumeName(binding), ReadOnly: true, @@ -321,7 +321,7 @@ func (p *serviceBindingProjector) projectVolumeMount(binding *servicebindingv1be }) } -func (p *serviceBindingProjector) unprojectVolumeMount(binding *servicebindingv1beta1.ServiceBinding, mc *metaContainer) { +func (p *serviceBindingProjector) unprojectVolumeMount(binding *servicebindingv1.ServiceBinding, mc *metaContainer) { mounts := []corev1.VolumeMount{} projected := p.volumeName(binding) for _, m := range mc.VolumeMounts { @@ -332,7 +332,7 @@ func (p *serviceBindingProjector) unprojectVolumeMount(binding *servicebindingv1 mc.VolumeMounts = mounts } -func (p *serviceBindingProjector) projectEnv(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { +func (p *serviceBindingProjector) projectEnv(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { for _, e := range binding.Spec.Env { if e.Key == "type" && binding.Spec.Type != "" { mc.Env = append(mc.Env, corev1.EnvVar{ @@ -389,7 +389,7 @@ func (p *serviceBindingProjector) projectEnv(binding *servicebindingv1beta1.Serv }) } -func (p *serviceBindingProjector) unprojectEnv(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { +func (p *serviceBindingProjector) unprojectEnv(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate, mc *metaContainer) { env := []corev1.EnvVar{} secret := mpt.PodTemplateAnnotations[p.secretAnnotationName(binding)] typeFieldPath := fmt.Sprintf("metadata.annotations['%s']", p.typeAnnotationName(binding)) @@ -418,7 +418,7 @@ func (p *serviceBindingProjector) unprojectEnv(binding *servicebindingv1beta1.Se mc.Env = env } -func (p *serviceBindingProjector) isContainerBindable(binding *servicebindingv1beta1.ServiceBinding, mc *metaContainer) bool { +func (p *serviceBindingProjector) isContainerBindable(binding *servicebindingv1.ServiceBinding, mc *metaContainer) bool { if len(binding.Spec.Workload.Containers) == 0 || mc.Name == nil { return true } @@ -467,14 +467,14 @@ func (p *serviceBindingProjector) knownProjectedSecrets(mpt *metaPodTemplate) se return secrets } -func (p *serviceBindingProjector) secretName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) secretName(binding *servicebindingv1.ServiceBinding) string { if binding.Status.Binding == nil { return "" } return binding.Status.Binding.Name } -func (p *serviceBindingProjector) secretAnnotation(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) string { +func (p *serviceBindingProjector) secretAnnotation(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) string { key := p.secretAnnotationName(binding) secret := p.secretName(binding) if secret == "" { @@ -484,35 +484,35 @@ func (p *serviceBindingProjector) secretAnnotation(binding *servicebindingv1beta return secret } -func (p *serviceBindingProjector) secretAnnotationName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) secretAnnotationName(binding *servicebindingv1.ServiceBinding) string { return fmt.Sprintf("%s%s", SecretAnnotationPrefix, binding.UID) } -func (p *serviceBindingProjector) volumeName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) volumeName(binding *servicebindingv1.ServiceBinding) string { return fmt.Sprintf("%s%s", VolumePrefix, binding.UID) } -func (p *serviceBindingProjector) typeAnnotation(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) string { +func (p *serviceBindingProjector) typeAnnotation(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) string { key := p.typeAnnotationName(binding) mpt.PodTemplateAnnotations[key] = binding.Spec.Type return key } -func (p *serviceBindingProjector) typeAnnotationName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) typeAnnotationName(binding *servicebindingv1.ServiceBinding) string { return fmt.Sprintf("%s%s", TypeAnnotationPrefix, binding.UID) } -func (p *serviceBindingProjector) providerAnnotation(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate) string { +func (p *serviceBindingProjector) providerAnnotation(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate) string { key := p.providerAnnotationName(binding) mpt.PodTemplateAnnotations[key] = binding.Spec.Provider return key } -func (p *serviceBindingProjector) providerAnnotationName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) providerAnnotationName(binding *servicebindingv1.ServiceBinding) string { return fmt.Sprintf("%s%s", ProviderAnnotationPrefix, binding.UID) } -func (p *serviceBindingProjector) retrieveLocalMapping(binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) (*servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, error) { +func (p *serviceBindingProjector) retrieveLocalMapping(binding *servicebindingv1.ServiceBinding, workload runtime.Object) (*servicebindingv1.ClusterWorkloadResourceMappingSpec, error) { annoations := workload.(metav1.Object).GetAnnotations() if annoations == nil { return nil, nil @@ -521,14 +521,14 @@ func (p *serviceBindingProjector) retrieveLocalMapping(binding *servicebindingv1 if !ok { return nil, nil } - var mapping servicebindingv1beta1.ClusterWorkloadResourceMappingSpec + var mapping servicebindingv1.ClusterWorkloadResourceMappingSpec if err := json.Unmarshal([]byte(data), &mapping); err != nil { return nil, err } return &mapping, nil } -func (p *serviceBindingProjector) stashLocalMapping(binding *servicebindingv1beta1.ServiceBinding, mpt *metaPodTemplate, mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec) error { +func (p *serviceBindingProjector) stashLocalMapping(binding *servicebindingv1.ServiceBinding, mpt *metaPodTemplate, mapping *servicebindingv1.ClusterWorkloadResourceMappingSpec) error { if mapping == nil { delete(mpt.WorkloadAnnotations, p.mappingAnnotationName(binding)) return nil @@ -541,6 +541,6 @@ func (p *serviceBindingProjector) stashLocalMapping(binding *servicebindingv1bet return nil } -func (p *serviceBindingProjector) mappingAnnotationName(binding *servicebindingv1beta1.ServiceBinding) string { +func (p *serviceBindingProjector) mappingAnnotationName(binding *servicebindingv1.ServiceBinding) string { return fmt.Sprintf("%s%s", MappingAnnotationPrefix, binding.UID) } diff --git a/projector/binding_test.go b/projector/binding_test.go index 291f4efb..05d954b3 100644 --- a/projector/binding_test.go +++ b/projector/binding_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func TestBinding(t *testing.T) { @@ -56,28 +56,28 @@ func TestBinding(t *testing.T) { tests := []struct { name string mapping MappingSource - binding *servicebindingv1beta1.ServiceBinding + binding *servicebindingv1.ServiceBinding workload runtime.Object expected runtime.Object expectedErr bool }{ { name: "podspecable", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -223,12 +223,12 @@ func TestBinding(t *testing.T) { }, { name: "almost podspecable", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -242,20 +242,20 @@ func TestBinding(t *testing.T) { }, }, }, cronJobRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "batch/v1", Kind: "CronJob", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -409,20 +409,20 @@ func TestBinding(t *testing.T) { }, { name: "almost podspecable, unbind with stashed mapping", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, cronJobRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, cronJobRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "batch/v1", Kind: "CronJob", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ + Status: servicebindingv1.ServiceBindingStatus{ Binding: nil, }, }, @@ -602,12 +602,12 @@ func TestBinding(t *testing.T) { }, { name: "almost podspecable, unbind with cluster mapping", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -621,19 +621,19 @@ func TestBinding(t *testing.T) { }, }, }, cronJobRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "batch/v1", Kind: "CronJob", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ + Status: servicebindingv1.ServiceBindingStatus{ Binding: nil, }, }, @@ -811,20 +811,20 @@ func TestBinding(t *testing.T) { }, { name: "almost podspecable, unable to unbind without mapping", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, cronJobRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, cronJobRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "batch/v1", Kind: "CronJob", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ + Status: servicebindingv1.ServiceBindingStatus{ Binding: nil, }, }, @@ -1045,21 +1045,21 @@ func TestBinding(t *testing.T) { }, { name: "no containers", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -1109,21 +1109,21 @@ func TestBinding(t *testing.T) { }, { name: "rotate binding secret", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName + "-updated", }, }, @@ -1236,14 +1236,14 @@ func TestBinding(t *testing.T) { }, { name: "project service binding env", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Env: []servicebindingv1beta1.EnvMapping{ + Env: []servicebindingv1.EnvMapping{ { Name: "FOO", Key: "foo", @@ -1253,14 +1253,14 @@ func TestBinding(t *testing.T) { Key: "bar", }, }, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -1358,21 +1358,21 @@ func TestBinding(t *testing.T) { }, { name: "remove service binding env", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -1507,14 +1507,14 @@ func TestBinding(t *testing.T) { }, { name: "update service binding env", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Env: []servicebindingv1beta1.EnvMapping{ + Env: []servicebindingv1.EnvMapping{ { Name: "BLEEP", Key: "bleep", @@ -1524,14 +1524,14 @@ func TestBinding(t *testing.T) { Key: "bloop", }, }, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -1688,16 +1688,16 @@ func TestBinding(t *testing.T) { }, { name: "project service binding type and provider for env and volume", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, Type: "my-type", Provider: "my-provider", - Env: []servicebindingv1beta1.EnvMapping{ + Env: []servicebindingv1.EnvMapping{ { Name: "TYPE", Key: "type", @@ -1707,14 +1707,14 @@ func TestBinding(t *testing.T) { Key: "provider", }, }, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -1832,14 +1832,14 @@ func TestBinding(t *testing.T) { }, { name: "update service binding type and provider", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Env: []servicebindingv1beta1.EnvMapping{ + Env: []servicebindingv1.EnvMapping{ { Name: "TYPE", Key: "type", @@ -1849,14 +1849,14 @@ func TestBinding(t *testing.T) { Key: "provider", }, }, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -2033,14 +2033,14 @@ func TestBinding(t *testing.T) { }, { name: "no binding if missing secret", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", @@ -2086,22 +2086,22 @@ func TestBinding(t *testing.T) { }, { name: "only bind to allowed containers", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", Containers: []string{"bind"}, }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -2196,27 +2196,27 @@ func TestBinding(t *testing.T) { }, { name: "preserve other bindings", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ + Spec: servicebindingv1.ServiceBindingSpec{ Name: bindingName, - Env: []servicebindingv1beta1.EnvMapping{ + Env: []servicebindingv1.EnvMapping{ { Name: "FOO", Key: "foo", }, }, - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -2587,20 +2587,20 @@ func TestBinding(t *testing.T) { }, { name: "apply binding should be idempotent", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{}, deploymentRESTMapping), + binding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ UID: uid, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", }, }, - Status: servicebindingv1beta1.ServiceBindingStatus{ - Binding: &servicebindingv1beta1.ServiceBindingSecretReference{ + Status: servicebindingv1.ServiceBindingStatus{ + Binding: &servicebindingv1.ServiceBindingSecretReference{ Name: secretName, }, }, @@ -2805,11 +2805,11 @@ func TestBinding(t *testing.T) { }, { name: "invalid container jsonpath", - mapping: NewStaticMapping(&servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: NewStaticMapping(&servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: "[", }, @@ -2817,9 +2817,9 @@ func TestBinding(t *testing.T) { }, }, }, deploymentRESTMapping), - binding: &servicebindingv1beta1.ServiceBinding{ - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + binding: &servicebindingv1.ServiceBinding{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", @@ -2836,7 +2836,7 @@ func TestBinding(t *testing.T) { { name: "conversion error", mapping: NewStaticMapping( - &servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{}, + &servicebindingv1.ClusterWorkloadResourceMappingSpec{}, &meta.RESTMapping{ GroupVersionKind: schema.GroupVersionKind{Group: "test", Version: "v1", Kind: "BadMarshalJSON"}, Resource: schema.GroupVersionResource{Group: "test", Version: "v1", Resource: "badmarshaljsons"}, diff --git a/projector/interface.go b/projector/interface.go index 2d249ceb..4b959cec 100644 --- a/projector/interface.go +++ b/projector/interface.go @@ -23,16 +23,16 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) type ServiceBindingProjector interface { // Project the service into the workload as defined by the ServiceBinding. - Project(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error + Project(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error // Unproject the service from the workload as defined by the ServiceBinding. - Unproject(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) error + Unproject(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) error // IsProjected returns true when the workload has been projected into by the binding - IsProjected(ctx context.Context, binding *servicebindingv1beta1.ServiceBinding, workload runtime.Object) bool + IsProjected(ctx context.Context, binding *servicebindingv1.ServiceBinding, workload runtime.Object) bool } type MappingSource interface { @@ -42,5 +42,5 @@ type MappingSource interface { // LookupWorkloadMapping the mapping template for the workload. Typically a ClusterWorkloadResourceMapping is defined for the // workload's fully qualified resource `{resource}.{group}`. - LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, error) + LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1.ClusterWorkloadResourceMappingSpec, error) } diff --git a/projector/mapping.go b/projector/mapping.go index af3695bc..5b09b9dc 100644 --- a/projector/mapping.go +++ b/projector/mapping.go @@ -23,14 +23,14 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // The workload's version is either directly matched, or the wildcard version `*` // mapping template is returned. If no explicit mapping is found, a mapping appropriate for a PodSpecable resource may be used. -func MappingVersion(version string, mappings *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec) *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate { - wildcardMapping := servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{Version: "*"} - var mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate +func MappingVersion(version string, mappings *servicebindingv1.ClusterWorkloadResourceMappingSpec) *servicebindingv1.ClusterWorkloadResourceMappingTemplate { + wildcardMapping := servicebindingv1.ClusterWorkloadResourceMappingTemplate{Version: "*"} + var mapping *servicebindingv1.ClusterWorkloadResourceMappingTemplate for _, v := range mappings.Versions { switch v.Version { case version: @@ -53,15 +53,15 @@ func MappingVersion(version string, mappings *servicebindingv1beta1.ClusterWorkl var _ MappingSource = (*staticMapping)(nil) type staticMapping struct { - workloadMapping *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec + workloadMapping *servicebindingv1.ClusterWorkloadResourceMappingSpec restMapping *meta.RESTMapping } // NewStaticMapping returns a single ClusterWorkloadResourceMappingSpec for each lookup. It is useful for // testing. -func NewStaticMapping(wm *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, rm *meta.RESTMapping) MappingSource { +func NewStaticMapping(wm *servicebindingv1.ClusterWorkloadResourceMappingSpec, rm *meta.RESTMapping) MappingSource { if len(wm.Versions) == 0 { - wm.Versions = []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + wm.Versions = []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", }, @@ -81,6 +81,6 @@ func (m *staticMapping) LookupRESTMapping(ctx context.Context, obj runtime.Objec return m.restMapping, nil } -func (m *staticMapping) LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, error) { +func (m *staticMapping) LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1.ClusterWorkloadResourceMappingSpec, error) { return m.workloadMapping, nil } diff --git a/projector/metapodtemplate.go b/projector/metapodtemplate.go index 03250b72..8ff40879 100644 --- a/projector/metapodtemplate.go +++ b/projector/metapodtemplate.go @@ -27,13 +27,13 @@ import ( "k8s.io/client-go/util/jsonpath" "k8s.io/utils/pointer" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // metaPodTemplate contains the subset of a PodTemplateSpec that is appropriate for service binding. type metaPodTemplate struct { workload runtime.Object - mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate + mapping *servicebindingv1.ClusterWorkloadResourceMappingTemplate WorkloadAnnotations map[string]string PodTemplateAnnotations map[string]string @@ -51,7 +51,7 @@ type metaContainer struct { // NewMetaPodTemplate coerces the workload object into a MetaPodTemplate following the mapping definition. The // resulting MetaPodTemplate may have one or more service bindings applied to it at a time, but should not be reused. // The workload must be JSON marshalable. -func NewMetaPodTemplate(ctx context.Context, workload runtime.Object, mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate) (*metaPodTemplate, error) { +func NewMetaPodTemplate(ctx context.Context, workload runtime.Object, mapping *servicebindingv1.ClusterWorkloadResourceMappingTemplate) (*metaPodTemplate, error) { mpt := &metaPodTemplate{ workload: workload, mapping: mapping, diff --git a/projector/metapodtemplate_test.go b/projector/metapodtemplate_test.go index a150f933..fda8791a 100644 --- a/projector/metapodtemplate_test.go +++ b/projector/metapodtemplate_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/pointer" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) func TestNewMetaPodTemplate(t *testing.T) { @@ -58,14 +58,14 @@ func TestNewMetaPodTemplate(t *testing.T) { tests := []struct { name string - mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate + mapping *servicebindingv1.ClusterWorkloadResourceMappingTemplate workload runtime.Object expected *metaPodTemplate expectedErr bool }{ { name: "podspecable", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, workload: &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Annotations: testWorkloadAnnotations, @@ -129,9 +129,9 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "almost podspecable", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -210,7 +210,7 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "no containers", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, workload: &appsv1.Deployment{}, expected: &metaPodTemplate{ WorkloadAnnotations: map[string]string{}, @@ -221,7 +221,7 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "empty container", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, workload: &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ Template: corev1.PodTemplateSpec{ @@ -248,9 +248,9 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "unmapped container name", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ Annotations: ".spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.template.spec.initContainers[*]", }, @@ -286,8 +286,8 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "misaligned path", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".foo.bar", }, @@ -332,9 +332,9 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "misaligned pointers", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ Annotations: ".foo/nar", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.template.spec.containers[*]", Name: ".foo.bar", @@ -380,8 +380,8 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "invalid container jsonpath", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: "[", }, @@ -392,7 +392,7 @@ func TestNewMetaPodTemplate(t *testing.T) { }, { name: "conversion error", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, workload: &BadMarshalJSON{}, expectedErr: true, }, @@ -447,7 +447,7 @@ func TestMetaPodTemplate_WriteToWorkload(t *testing.T) { tests := []struct { name string - mapping *servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate + mapping *servicebindingv1.ClusterWorkloadResourceMappingTemplate metadata metaPodTemplate workload runtime.Object expected runtime.Object @@ -455,7 +455,7 @@ func TestMetaPodTemplate_WriteToWorkload(t *testing.T) { }{ { name: "podspecable", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, metadata: metaPodTemplate{ WorkloadAnnotations: testWorkloadAnnotations, PodTemplateAnnotations: testPodTemplateAnnotations, @@ -541,9 +541,9 @@ func TestMetaPodTemplate_WriteToWorkload(t *testing.T) { }, { name: "almost podspecable", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{ Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -648,7 +648,7 @@ func TestMetaPodTemplate_WriteToWorkload(t *testing.T) { }, { name: "no containers", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, metadata: metaPodTemplate{ WorkloadAnnotations: map[string]string{}, PodTemplateAnnotations: map[string]string{}, @@ -674,7 +674,7 @@ func TestMetaPodTemplate_WriteToWorkload(t *testing.T) { }, { name: "empty container", - mapping: &servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{}, + mapping: &servicebindingv1.ClusterWorkloadResourceMappingTemplate{}, metadata: metaPodTemplate{ WorkloadAnnotations: map[string]string{}, PodTemplateAnnotations: map[string]string{}, diff --git a/resolver/cluster.go b/resolver/cluster.go index efb49418..e0f2d8ff 100644 --- a/resolver/cluster.go +++ b/resolver/cluster.go @@ -31,7 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) // New creates a new resolver backed by a controller-runtime client @@ -57,15 +57,15 @@ func (m *clusterResolver) LookupRESTMapping(ctx context.Context, obj runtime.Obj return rm, nil } -func (m *clusterResolver) LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, error) { - wrm := &servicebindingv1beta1.ClusterWorkloadResourceMapping{} +func (m *clusterResolver) LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1.ClusterWorkloadResourceMappingSpec, error) { + wrm := &servicebindingv1.ClusterWorkloadResourceMapping{} if err := m.client.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s.%s", gvr.Resource, gvr.Group)}, wrm); err != nil { if !apierrs.IsNotFound(err) { return nil, err } - wrm.Spec = servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + wrm.Spec = servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", }, @@ -80,7 +80,7 @@ func (m *clusterResolver) LookupWorkloadMapping(ctx context.Context, gvr schema. return &wrm.Spec, nil } -func (r *clusterResolver) LookupBindingSecret(ctx context.Context, serviceBinding *servicebindingv1beta1.ServiceBinding) (string, error) { +func (r *clusterResolver) LookupBindingSecret(ctx context.Context, serviceBinding *servicebindingv1.ServiceBinding) (string, error) { serviceRef := serviceBinding.Spec.Service if serviceRef.APIVersion == "v1" && serviceRef.Kind == "Secret" { // direct secret reference @@ -102,7 +102,7 @@ const ( mappingAnnotationPrefix = "projector.servicebinding.io/mapping-" ) -func (r *clusterResolver) LookupWorkloads(ctx context.Context, serviceBinding *servicebindingv1beta1.ServiceBinding) ([]runtime.Object, error) { +func (r *clusterResolver) LookupWorkloads(ctx context.Context, serviceBinding *servicebindingv1.ServiceBinding) ([]runtime.Object, error) { workloadRef := serviceBinding.Spec.Workload list := &unstructured.UnstructuredList{} diff --git a/resolver/cluster_test.go b/resolver/cluster_test.go index ce36438d..fd84c4f1 100644 --- a/resolver/cluster_test.go +++ b/resolver/cluster_test.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" "github.com/servicebinding/runtime/projector" "github.com/servicebinding/runtime/resolver" ) @@ -46,7 +46,7 @@ func TestClusterResolver_LookupRESTMapping(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(appsv1.AddToScheme(scheme)) utilruntime.Must(batchv1.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) deploymentRESTMapping := &meta.RESTMapping{ GroupVersionKind: schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}, @@ -81,12 +81,12 @@ func TestClusterResolver_LookupRESTMapping(t *testing.T) { { name: "error if workload type not found in scheme", givenObjects: []client.Object{ - &servicebindingv1beta1.ClusterWorkloadResourceMapping{ + &servicebindingv1.ClusterWorkloadResourceMapping{ ObjectMeta: metav1.ObjectMeta{ Name: "myworkloads.workload.local", }, - Spec: servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + Spec: servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", }, @@ -101,12 +101,12 @@ func TestClusterResolver_LookupRESTMapping(t *testing.T) { { name: "error if workload type not found in restmapper", givenObjects: []client.Object{ - &servicebindingv1beta1.ClusterWorkloadResourceMapping{ + &servicebindingv1.ClusterWorkloadResourceMapping{ ObjectMeta: metav1.ObjectMeta{ Name: "myworkloads.workload.local", }, - Spec: servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + Spec: servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", }, @@ -157,13 +157,13 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { scheme := runtime.NewScheme() utilruntime.Must(appsv1.AddToScheme(scheme)) utilruntime.Must(batchv1.AddToScheme(scheme)) - utilruntime.Must(servicebindingv1beta1.AddToScheme(scheme)) + utilruntime.Must(servicebindingv1.AddToScheme(scheme)) tests := []struct { name string givenObjects []client.Object gvr schema.GroupVersionResource - expected *servicebindingv1beta1.ClusterWorkloadResourceMappingSpec + expected *servicebindingv1.ClusterWorkloadResourceMappingSpec expectedRESTMapping *meta.RESTMapping expectedErr bool }{ @@ -171,12 +171,12 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { name: "default mapping", givenObjects: []client.Object{}, gvr: schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}, - expected: &servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + expected: &servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", Annotations: ".spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.template.spec.initContainers[*]", Name: ".name", @@ -198,16 +198,16 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { { name: "custom mapping", givenObjects: []client.Object{ - &servicebindingv1beta1.ClusterWorkloadResourceMapping{ + &servicebindingv1.ClusterWorkloadResourceMapping{ ObjectMeta: metav1.ObjectMeta{ Name: "cronjobs.batch", }, - Spec: servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + Spec: servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "v1", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -224,12 +224,12 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { }, }, gvr: schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "cronjobs"}, - expected: &servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + expected: &servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "v1", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -251,16 +251,16 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { { name: "custom mapping with wildcard", givenObjects: []client.Object{ - &servicebindingv1beta1.ClusterWorkloadResourceMapping{ + &servicebindingv1.ClusterWorkloadResourceMapping{ ObjectMeta: metav1.ObjectMeta{ Name: "cronjobs.batch", }, - Spec: servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + Spec: servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -277,12 +277,12 @@ func TestClusterResolver_LookupWorkloadMapping(t *testing.T) { }, }, gvr: schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "cronjobs"}, - expected: &servicebindingv1beta1.ClusterWorkloadResourceMappingSpec{ - Versions: []servicebindingv1beta1.ClusterWorkloadResourceMappingTemplate{ + expected: &servicebindingv1.ClusterWorkloadResourceMappingSpec{ + Versions: []servicebindingv1.ClusterWorkloadResourceMappingTemplate{ { Version: "*", Annotations: ".spec.jobTemplate.spec.template.metadata.annotations", - Containers: []servicebindingv1beta1.ClusterWorkloadResourceMappingContainer{ + Containers: []servicebindingv1.ClusterWorkloadResourceMappingContainer{ { Path: ".spec.jobTemplate.spec.template.spec.initContainers[*]", Name: ".name", @@ -335,19 +335,19 @@ func TestClusterResolver_LookupBindingSecret(t *testing.T) { tests := []struct { name string givenObjects []client.Object - serviceBinding *servicebindingv1beta1.ServiceBinding + serviceBinding *servicebindingv1.ServiceBinding expected string expectedErr bool }{ { name: "direct binding", givenObjects: []client.Object{}, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Service: servicebindingv1beta1.ServiceBindingServiceReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Service: servicebindingv1.ServiceBindingServiceReference{ APIVersion: "v1", Kind: "Secret", Name: "my-secret", @@ -375,12 +375,12 @@ func TestClusterResolver_LookupBindingSecret(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Service: servicebindingv1beta1.ServiceBindingServiceReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Service: servicebindingv1.ServiceBindingServiceReference{ APIVersion: "service.local/v1", Kind: "ProvisionedService", Name: "my-service", @@ -404,12 +404,12 @@ func TestClusterResolver_LookupBindingSecret(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Service: servicebindingv1beta1.ServiceBindingServiceReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Service: servicebindingv1.ServiceBindingServiceReference{ APIVersion: "service.local/v1", Kind: "NotAProvisionedService", Name: "my-service", @@ -421,12 +421,12 @@ func TestClusterResolver_LookupBindingSecret(t *testing.T) { { name: "not found", givenObjects: []client.Object{}, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Service: servicebindingv1beta1.ServiceBindingServiceReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Service: servicebindingv1.ServiceBindingServiceReference{ APIVersion: "service.local/v1", Kind: "ProvisionedService", Name: "my-service", @@ -471,20 +471,20 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { tests := []struct { name string givenObjects []client.Object - serviceBinding *servicebindingv1beta1.ServiceBinding + serviceBinding *servicebindingv1.ServiceBinding expected []runtime.Object expectedErr bool }{ { name: "not found", givenObjects: []client.Object{}, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", @@ -506,13 +506,13 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", @@ -558,13 +558,13 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Name: "my-workload", @@ -611,13 +611,13 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "workload.local/v1", Kind: "MyWorkload", Name: "my-workload", @@ -668,13 +668,13 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "apps/v1", Kind: "Deployment", Selector: &metav1.LabelSelector{ @@ -783,13 +783,13 @@ func TestClusterResolver_LookupWorkloads(t *testing.T) { }, }, }, - serviceBinding: &servicebindingv1beta1.ServiceBinding{ + serviceBinding: &servicebindingv1.ServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Namespace: "my-namespace", UID: bindingUID, }, - Spec: servicebindingv1beta1.ServiceBindingSpec{ - Workload: servicebindingv1beta1.ServiceBindingWorkloadReference{ + Spec: servicebindingv1.ServiceBindingSpec{ + Workload: servicebindingv1.ServiceBindingWorkloadReference{ APIVersion: "workload.local/v1", Kind: "MyWorkload", Selector: &metav1.LabelSelector{ diff --git a/resolver/interface.go b/resolver/interface.go index 2dc1294c..589f449d 100644 --- a/resolver/interface.go +++ b/resolver/interface.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - servicebindingv1beta1 "github.com/servicebinding/runtime/apis/v1beta1" + servicebindingv1 "github.com/servicebinding/runtime/apis/v1" ) type Resolver interface { @@ -33,15 +33,15 @@ type Resolver interface { // LookupWorkloadMapping the mapping template for the workload. Typically a ClusterWorkloadResourceMapping is defined for the // workload's fully qualified resource `{resource}.{group}`. - LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1beta1.ClusterWorkloadResourceMappingSpec, error) + LookupWorkloadMapping(ctx context.Context, gvr schema.GroupVersionResource) (*servicebindingv1.ClusterWorkloadResourceMappingSpec, error) // LookupBindingSecret returns the binding secret name exposed by the service following the Provisioned Service duck-type // (`.status.binding.name`). If a direction binding is used (where the referenced service is itself a Secret) the referenced Secret is // returned without a lookup. - LookupBindingSecret(ctx context.Context, serviceBinding *servicebindingv1beta1.ServiceBinding) (string, error) + LookupBindingSecret(ctx context.Context, serviceBinding *servicebindingv1.ServiceBinding) (string, error) // LookupWorkloads returns the referenced objects. Often a unstructured Object is used to sidestep issues with schemes and registered // types. The selector is mutually exclusive with the reference name. The UID of the ServiceBinding is used to find resources that // may have been previously bound but no longer match the query. - LookupWorkloads(ctx context.Context, serviceBinding *servicebindingv1beta1.ServiceBinding) ([]runtime.Object, error) + LookupWorkloads(ctx context.Context, serviceBinding *servicebindingv1.ServiceBinding) ([]runtime.Object, error) } diff --git a/samples/controlled-resource/service-binding.yaml b/samples/controlled-resource/service-binding.yaml index c4391dd6..3121dae8 100644 --- a/samples/controlled-resource/service-binding.yaml +++ b/samples/controlled-resource/service-binding.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: controlled-resource diff --git a/samples/external-secrets/kapp-config.yaml b/samples/external-secrets/kapp-config.yaml index 97bb0818..ed0f2e41 100644 --- a/samples/external-secrets/kapp-config.yaml +++ b/samples/external-secrets/kapp-config.yaml @@ -35,7 +35,7 @@ data: status: "True" success: true resourceMatchers: - - apiVersionKindMatcher: {apiVersion: servicebinding.io/v1beta1, kind: ServiceBinding} + - apiVersionKindMatcher: {apiVersion: servicebinding.io/v1, kind: ServiceBinding} - supportsObservedGeneration: false conditionMatchers: - type: Ready diff --git a/samples/external-secrets/service-binding.yaml b/samples/external-secrets/service-binding.yaml index e3cae84f..4cb423eb 100644 --- a/samples/external-secrets/service-binding.yaml +++ b/samples/external-secrets/service-binding.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: eso-example diff --git a/samples/external-secrets/service.yaml b/samples/external-secrets/service.yaml index fe9d6007..4170d843 100644 --- a/samples/external-secrets/service.yaml +++ b/samples/external-secrets/service.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: eso-example-db diff --git a/samples/multi-binding/service-binding.yaml b/samples/multi-binding/service-binding.yaml index bde4d42e..ef7e110a 100644 --- a/samples/multi-binding/service-binding.yaml +++ b/samples/multi-binding/service-binding.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: multi-binding-1 @@ -34,7 +34,7 @@ spec: key: number --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: multi-binding-2 diff --git a/samples/overridden-type-provider/service-binding.yaml b/samples/overridden-type-provider/service-binding.yaml index c9e1e6ab..fe005972 100644 --- a/samples/overridden-type-provider/service-binding.yaml +++ b/samples/overridden-type-provider/service-binding.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: overridden-type-provider diff --git a/samples/spring-petclinic/kapp-config.yaml b/samples/spring-petclinic/kapp-config.yaml index 3eeced10..b528e189 100644 --- a/samples/spring-petclinic/kapp-config.yaml +++ b/samples/spring-petclinic/kapp-config.yaml @@ -35,4 +35,4 @@ data: status: "True" success: true resourceMatchers: - - apiVersionKindMatcher: {apiVersion: servicebinding.io/v1beta1, kind: ServiceBinding} + - apiVersionKindMatcher: {apiVersion: servicebinding.io/v1, kind: ServiceBinding} diff --git a/samples/spring-petclinic/service-binding.yaml b/samples/spring-petclinic/service-binding.yaml index 69462e10..18780a54 100644 --- a/samples/spring-petclinic/service-binding.yaml +++ b/samples/spring-petclinic/service-binding.yaml @@ -13,7 +13,7 @@ # limitations under the License. --- -apiVersion: servicebinding.io/v1beta1 +apiVersion: servicebinding.io/v1 kind: ServiceBinding metadata: name: spring-petclinic-db