awslabs / aws-servicebroker

AWS Service Broker
Apache License 2.0
468 stars 131 forks source link

Output keys from OSB costs convention to be lower-case as CF expects #245

Closed tealeg closed 2 years ago

tealeg commented 3 years ago

Overview

This PR makes a minor correction to the JSON output for a Service Plan in the catalogue. Previously we added support for the costs convention used by some applications (e.g. Stratos, CloudFoundry). Unfortunately, we tested this code with clients that were case-insensitive, but in practice CloudFoundry expects the keys "amount" and "unit" to be lowercase. This PR achieves that by adding JSON annotations to the structure that are used by encoding/json when marshalling the struct.

Related Issues

Fixes #244

Testing

I have added a sub-test to the existing unit test which tests that the JSON output format is correct.

Additionally, I have deployed this in our Cloud Foundry environment and seen that the cf marketplace -e <service name> command produces output including the cost data, z.B.:

broker: ocf-aws-services-broker
   plan                    description                  free or paid   costs                                    available
   DevTest                 db.t3.micro / 20GB / No-HA   paid           EUR 15.35/Monthly, USD 18.07/Monthly     yes
   ProdGradeBurstable      db.t3.micro / 20GB / HA      paid           EUR 28.38/Monthly, USD 33.40/Monthly     yes
   ProdGradeNonBurstable   db.m5.large / EBS / HA       paid           EUR 296.38/Monthly, USD 251.81/Monthly   yes
   DevTestNew              db.t3.micro / 20GB / No-HA   paid                                                    no

Testing Instructions

Deploy the service broker to a cloud-foundry foundation. Add costs data to a service plan, e.g.:

        Costs:
        - Amount:
            EUR: 28.38
            USD: 33.40
          Unit: Monthly

See that cf marketplace reports the price information correctly (see above).

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.