From 781f3b910bb2f2b14b915e76e6856eb5b6424a4a Mon Sep 17 00:00:00 2001 From: John Poth Date: Thu, 4 Mar 2021 13:25:08 +0100 Subject: [PATCH 1/2] chore: Upgrade ServiceBindingOperator to v0.5.0 #2077 --- go.mod | 2 +- go.sum | 5 +++-- pkg/trait/service_binding.go | 25 +++++++++++++------------ pkg/trait/trait_types.go | 8 ++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index d2c31e8c07..44cec2e743 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.42.1 github.com/prometheus/client_golang v1.7.1 github.com/radovskyb/watcher v1.0.6 - github.com/redhat-developer/service-binding-operator v0.4.1-0.20210217004726-4f7892420a13 + github.com/redhat-developer/service-binding-operator v0.5.0 github.com/rs/xid v1.2.1 github.com/scylladb/go-set v1.0.2 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 diff --git a/go.sum b/go.sum index 93ab264296..72c11ac872 100644 --- a/go.sum +++ b/go.sum @@ -1044,8 +1044,8 @@ github.com/radovskyb/watcher v1.0.6 h1:8WIQ9UxEYMZjem1OwU7dVH94DXXk9mAIE1i8eqHD+ github.com/radovskyb/watcher v1.0.6/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/redhat-developer/service-binding-operator v0.4.1-0.20210217004726-4f7892420a13 h1:tRpj5V6u+D8hK0GieODXZkpfzziH3wgtfnhxIX3iGLc= -github.com/redhat-developer/service-binding-operator v0.4.1-0.20210217004726-4f7892420a13/go.mod h1:pnMK07Z13eYWFrta6rIcrGjWg1ESEQZLfpu6wcXMfY8= +github.com/redhat-developer/service-binding-operator v0.5.0 h1:qai/SDUEOnsLlHEa0seFJ1sT7dRemFc/1Y3Q7MeYng8= +github.com/redhat-developer/service-binding-operator v0.5.0/go.mod h1:pnMK07Z13eYWFrta6rIcrGjWg1ESEQZLfpu6wcXMfY8= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/rickb777/date v1.13.0 h1:+8AmwLuY1d/rldzdqvqTEg7107bZ8clW37x4nsdG3Hs= github.com/rickb777/date v1.13.0/go.mod h1:GZf3LoGnxPWjX+/1TXOuzHefZFDovTyNLHDMd3qH70k= @@ -1921,6 +1921,7 @@ k8s.io/code-generator v0.18.4/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8 k8s.io/code-generator v0.18.6/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c= k8s.io/code-generator v0.18.8/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c= k8s.io/code-generator v0.19.2/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk= +k8s.io/code-generator v0.19.8 h1:uxctqO1/3jnMDWB4imT8unRvgCXVPX2NTm/cMFCyigY= k8s.io/code-generator v0.19.8/go.mod h1:lwEq3YnLYb/7uVXLorOJfxg+cUu2oihFhHZ0n9NIla0= k8s.io/component-base v0.0.0-20190918200425-ed2f0867c778/go.mod h1:DFWQCXgXVLiWtzFaS17KxHdlUeUymP7FLxZSkmL9/jU= k8s.io/component-base v0.16.4/go.mod h1:GYQ+4hlkEwdlpAp59Ztc4gYuFhdoZqiAJD1unYDJ3FM= diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go index 0e1fbc1fe4..a78143eb8d 100644 --- a/pkg/trait/service_binding.go +++ b/pkg/trait/service_binding.go @@ -195,15 +195,15 @@ func (t *serviceBindingTrait) parseProvisionedServices(e *Environment) ([]sb.Ser namespace = seg[2] } service := sb.Service{ - GroupVersionKind: metav1.GroupVersionKind{ - Group: group, - Version: version, - Kind: kind, + NamespacedRef: sb.NamespacedRef{ + Ref: sb.Ref{ + Group: group, + Version: version, + Kind: kind, + Name: name, + }, + Namespace: &namespace, }, - LocalObjectReference: corev1.LocalObjectReference{ - Name: name, - }, - Namespace: &namespace, } services = append(services, service) } @@ -222,8 +222,8 @@ func (t *serviceBindingTrait) parseServiceBindings(e *Environment) ([]string, er kind := seg[0][0:index] if kind == "ServiceBinding" { vg := seg[0][index+1 : len(gvk)] - if vg != "v1alpha1.operators.coreos.com" { - return nil, fmt.Errorf("ServiceBinding: %s VERSION.GROUP should be v1alpha1.operators.coreos.com", s) + if vg != "v1alpha1.binding.operators.coreos.com" { + return nil, fmt.Errorf("ServiceBinding: %s VERSION.GROUP should be v1alpha1.binding.operators.coreos.com", s) } if len(seg) == 3 && seg[2] != e.Integration.Namespace { return nil, fmt.Errorf("ServiceBinding: %s should be in the same namespace %s as the integration", s, e.Integration.Namespace) @@ -236,7 +236,8 @@ func (t *serviceBindingTrait) parseServiceBindings(e *Environment) ([]string, er func createServiceBinding(e *Environment, services []sb.Service, name string) sb.ServiceBinding { spec := sb.ServiceBindingSpec{ - Services: services, + NamingStrategy: "none", + Services: services, } labels := map[string]string{ v1.IntegrationLabel: e.Integration.Name, @@ -244,7 +245,7 @@ func createServiceBinding(e *Environment, services []sb.Service, name string) sb serviceBinding := sb.ServiceBinding{ TypeMeta: metav1.TypeMeta{ Kind: "ServiceBinding", - APIVersion: "operators.coreos.com/v1alpha1", + APIVersion: "binding.operators.coreos.com/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{ Namespace: e.Integration.Namespace, diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go index 5b360d08c4..c97caf41de 100644 --- a/pkg/trait/trait_types.go +++ b/pkg/trait/trait_types.go @@ -706,21 +706,21 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c // Volumes :: Additional Secrets // // append Service Binding secrets - for _, name := range e.ServiceBindings { - refName := kubernetes.SanitizeLabel(name) + for sb, secret := range e.ServiceBindings { + refName := kubernetes.SanitizeLabel(sb) *vols = append(*vols, corev1.Volume{ Name: refName, VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: name, + SecretName: secret, }, }, }) *mnts = append(*mnts, corev1.VolumeMount{ Name: refName, - MountPath: path.Join(serviceBindingsMountPath, strings.ToLower(name)), + MountPath: path.Join(serviceBindingsMountPath, strings.ToLower(sb)), }) } for _, secretName := range e.collectConfigurationValues("secret") { From cb28ac1713cbd3f298acba2801223ae3ee9ad0af Mon Sep 17 00:00:00 2001 From: John Poth Date: Thu, 4 Mar 2021 13:41:46 +0100 Subject: [PATCH 2/2] chore: name the ServiceBinding simply to the integration name --- pkg/trait/service_binding.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go index a78143eb8d..d8ebb3a922 100644 --- a/pkg/trait/service_binding.go +++ b/pkg/trait/service_binding.go @@ -66,7 +66,6 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, error) { } func (t *serviceBindingTrait) Apply(e *Environment) error { - integrationServiceBindingName := e.Integration.Name + "-service-binding-request" services, err := t.parseProvisionedServices(e) if err != nil { return err @@ -76,19 +75,19 @@ func (t *serviceBindingTrait) Apply(e *Environment) error { return err } if len(services) > 0 { - serviceBindings = append(serviceBindings, integrationServiceBindingName) + serviceBindings = append(serviceBindings, e.Integration.Name) } if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) { serviceBindingsCollectionReady := true for _, name := range serviceBindings { - isIntSB := name == integrationServiceBindingName + isIntSB := name == e.Integration.Name serviceBinding, err := t.getServiceBinding(e, name) // Do not throw an error if the ServiceBinding is not found and if we are managing it: we will create it if (err != nil && !k8serrors.IsNotFound(err)) || (err != nil && !isIntSB) { return err } if isIntSB { - request := createServiceBinding(e, services, integrationServiceBindingName) + request := createServiceBinding(e, services, e.Integration.Name) e.Resources.Add(&request) } if isCollectionReady(serviceBinding) { @@ -134,8 +133,8 @@ func (t *serviceBindingTrait) Apply(e *Environment) error { return nil } e.ServiceBindings[name] = sb.Status.Secret - if name == integrationServiceBindingName { - request := createServiceBinding(e, services, integrationServiceBindingName) + if name == e.Integration.Name { + request := createServiceBinding(e, services, e.Integration.Name) e.Resources.Add(&request) } }