Skip to content

Commit

Permalink
Set 'provider' in default user secret
Browse files Browse the repository at this point in the history
- follow recommendation on provisioned service
binding spec
  • Loading branch information
ChunyiLyu committed Feb 22, 2021
1 parent 2a99e5c commit 32c46ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/resource/default_user_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

const (
DefaultUserSecretName = "default-user"
BindingProvider = "rabbitmq"
)

type DefaultUserSecretBuilder struct {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions internal/resource/default_user_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})
})
})

Expand Down

0 comments on commit 32c46ee

Please sign in to comment.