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 59b8ffc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/reconcile_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (r *RabbitmqClusterReconciler) setDefaultUserStatus(ctx context.Context, rm
return nil
}

// Status.Bindings exposes the default user secret which contains the binding
// Status.Binding exposes the default user secret which contains the binding
// information for this RabbitmqCluster.
// Default user secret implements the service binding Provisioned Service
// See: https://k8s-service-bindings.github.io/spec/#provisioned-service
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/sclevine/yj v0.0.0-20200815061347-554173e71934
github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e
gopkg.in/ini.v1 v1.62.0
k8s.io/api v0.20.2
k8s.io/apimachinery v0.20.3
Expand Down
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 59b8ffc

Please sign in to comment.