From 32c46eee639367ba3dcefbdfcaa26abd907146dc Mon Sep 17 00:00:00 2001 From: Chunyi Lyu Date: Mon, 22 Feb 2021 12:19:40 +0000 Subject: [PATCH] Set 'provider' in default user secret - follow recommendation on provisioned service binding spec --- internal/resource/default_user_secret.go | 4 ++++ internal/resource/default_user_secret_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/internal/resource/default_user_secret.go b/internal/resource/default_user_secret.go index 6571938dd..80e84b6d7 100644 --- a/internal/resource/default_user_secret.go +++ b/internal/resource/default_user_secret.go @@ -26,6 +26,7 @@ import ( const ( DefaultUserSecretName = "default-user" + BindingProvider = "rabbitmq" ) type DefaultUserSecretBuilder struct { @@ -62,7 +63,10 @@ func (builder *DefaultUserSecretBuilder) Build() (client.Object, error) { Namespace: builder.Instance.Namespace, }, Type: corev1.SecretTypeOpaque, + // Default user secret implements the service binding Provisioned Service + // See: https://k8s-service-bindings.github.io/spec/#provisioned-service Data: map[string][]byte{ + "provider": []byte(BindingProvider), "username": []byte(username), "password": []byte(password), "default_user.conf": defaultUserConf, diff --git a/internal/resource/default_user_secret_test.go b/internal/resource/default_user_secret_test.go index 0c198086a..314f3e9cc 100644 --- a/internal/resource/default_user_secret_test.go +++ b/internal/resource/default_user_secret_test.go @@ -99,6 +99,12 @@ var _ = Describe("DefaultUserSecret", func() { Expect(cfg.Section("").Key("default_user").Value()).To(Equal(string(username))) Expect(cfg.Section("").Key("default_pass").Value()).To(Equal(string(password))) }) + + By("setting 'provider' to 'rabbitmq' ", func() { + provider, ok := secret.Data["provider"] + Expect(ok).NotTo(BeFalse(), "Failed to find key 'provider' ") + Expect(string(provider)).To(Equal("rabbitmq")) + }) }) })