score-spec / score-compose

Reference implementation for docker-compose target platform support
https://docs.score.dev/docs/score-implementation/score-compose/
Apache License 2.0
448 stars 42 forks source link

feat: added rabbitmq/amqp provisioner #114

Closed astromechza closed 6 months ago

astromechza commented 6 months ago

We have a usecase for a rabbitmq provisioner to generate a stateful message broker.

This PR adds it :)

When I run the example project I can see:

INFO: Writing new state directory '.score-compose'
INFO: Writing new state directory '.score-compose' with project name '10-amqp-rabbitmq'
INFO: Writing default provisioners yaml file '99-default.provisioners.yaml'
INFO: Found existing Score file './score.yaml'
INFO: Read more about the Score specification at https://docs.score.dev/docs/
INFO: Loaded state directory with docker compose project '10-amqp-rabbitmq'
INFO: Validated workload 'hello-world'
INFO: Successfully loaded 8 resource provisioners
INFO: Provisioned 2 resources
INFO: Converting workload 'hello-world' to Docker compose
[+] Running 4/6
 ⠧ Network 10-amqp-rabbitmq_default                   Created                                                                                                                                                                                                                                                                                                       12.7s
 ⠧ Volume "10-amqp-rabbitmq_rabbitmq-mVawRj-data"     Created                                                                                                                                                                                                                                                                                                       12.6s
 ✔ Container 10-amqp-rabbitmq-rabbitmq-mVawRj-1       Healthy                                                                                                                                                                                                                                                                                                        7.8s
 ✔ Container 10-amqp-rabbitmq-rabbitmq-mVawRj-init-1  Exited                                                                                                                                                                                                                                                                                                         7.8s
 ✔ Container 10-amqp-rabbitmq-wait-for-resources-1    Started                                                                                                                                                                                                                                                                                                       12.4s
 ✔ Container 10-amqp-rabbitmq-hello-world-first-1     Started

The logs for the init container show both users and vhosts being created:

Adding vhost "vhost-MHZYFUaA" ...
Adding user "user-kNyzYLtt" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.
Setting tags for user "user-kNyzYLtt" to [administrator] ...
Setting permissions for user "user-kNyzYLtt" in vhost "vhost-MHZYFUaA" ...
Setting topic permissions on ".*" for user "user-kNyzYLtt" in vhost "vhost-MHZYFUaA" ...
Adding vhost "vhost-eOOSiqTF" ...
Adding user "user-uGCebmJZ" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.
Setting tags for user "user-uGCebmJZ" to [administrator] ...
Setting permissions for user "user-uGCebmJZ" in vhost "vhost-eOOSiqTF" ...
Setting topic permissions on ".*" for user "user-uGCebmJZ" in vhost "vhost-eOOSiqTF" ...

And the port is available through the browser:

image