From 1584fea8839f917e023b7fd559722e84e211af11 Mon Sep 17 00:00:00 2001 From: Debaditya Date: Fri, 18 Oct 2024 15:20:10 +0530 Subject: [PATCH] Added service plans datasource --- docs/data-sources/service.md | 38 -- docs/data-sources/service_plans.md | 111 +++++ docs/resources/service_instance.md | 22 +- .../cloudfoundry_service/data-source.tf | 7 - .../cloudfoundry_service_plans/data-source.tf | 7 + .../cloudfoundry_service_instance/resource.tf | 22 +- internal/provider/datasource_service.go | 157 ------- internal/provider/datasource_service_plans.go | 255 +++++++++++ .../provider/datasource_service_plans_test.go | 105 +++++ internal/provider/datasource_service_test.go | 113 ----- .../provider/fixtures/datasource_service.yaml | 405 ------------------ ...atasource_service_invalid_servicename.yaml | 70 --- .../fixtures/datasource_service_plans.yaml | 375 ++++++++++++++++ .../datasource_service_plans_invalid.yaml | 127 ++++++ internal/provider/provider.go | 2 +- internal/provider/provider_test.go | 2 +- internal/provider/types_service_plan.go | 241 +++++++++++ migration-guide/Readme.md | 2 +- migration-guide/data-sources/service.md | 19 - 19 files changed, 1248 insertions(+), 832 deletions(-) delete mode 100644 docs/data-sources/service.md create mode 100644 docs/data-sources/service_plans.md delete mode 100644 examples/data-sources/cloudfoundry_service/data-source.tf create mode 100644 examples/data-sources/cloudfoundry_service_plans/data-source.tf delete mode 100644 internal/provider/datasource_service.go create mode 100644 internal/provider/datasource_service_plans.go create mode 100644 internal/provider/datasource_service_plans_test.go delete mode 100644 internal/provider/datasource_service_test.go delete mode 100644 internal/provider/fixtures/datasource_service.yaml delete mode 100644 internal/provider/fixtures/datasource_service_invalid_servicename.yaml create mode 100644 internal/provider/fixtures/datasource_service_plans.yaml create mode 100644 internal/provider/fixtures/datasource_service_plans_invalid.yaml create mode 100644 internal/provider/types_service_plan.go delete mode 100644 migration-guide/data-sources/service.md diff --git a/docs/data-sources/service.md b/docs/data-sources/service.md deleted file mode 100644 index 81298bb..0000000 --- a/docs/data-sources/service.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -page_title: "cloudfoundry_service Data Source - terraform-provider-cloudfoundry" -subcategory: "" -description: |- - Get Service Offering and its related plans ---- - -# cloudfoundry_service (Data Source) - -Get Service Offering and its related plans - -## Example Usage - -```terraform -data "cloudfoundry_service" "xsuaa-offering" { - name = "xsuaa" -} - -output "serviceplans" { - value = data.cloudfoundry_service.xsuaa-offering.service_plans -} -``` - - -## Schema - -### Required - -- `name` (String) Name of the Service Offering - -### Optional - -- `service_broker` (String) The GUID of the service broker which offers the service. Use this to filter two equally named services from different brokers. - -### Read-Only - -- `id` (String) GUID of the service offering -- `service_plans` (Map of String) Map of service plan GUIDs keyed by service plan name \ No newline at end of file diff --git a/docs/data-sources/service_plans.md b/docs/data-sources/service_plans.md new file mode 100644 index 0000000..7d63527 --- /dev/null +++ b/docs/data-sources/service_plans.md @@ -0,0 +1,111 @@ +--- +page_title: "cloudfoundry_service_plans Data Source - terraform-provider-cloudfoundry" +subcategory: "" +description: |- + Fetches Service Plans based on the filters provided +--- + +# cloudfoundry_service_plans (Data Source) + +Fetches Service Plans based on the filters provided + +## Example Usage + +```terraform +data "cloudfoundry_service_plans" "xsuaa-offering" { + service_offering_name = "xsuaa" +} + +output "serviceplans" { + value = data.cloudfoundry_service_plans.xsuaa-offering.service_plans +} +``` + + +## Schema + +### Optional + +- `name` (String) The name of the service plan to look up +- `service_broker_name` (String) The name of the service broker which offers the service. Use this to filter two equally named services from different brokers. +- `service_offering_name` (String) The name of the service offering for whose plans to look up + +### Read-Only + +- `service_plans` (Attributes List) The list of the service plans (see [below for nested schema](#nestedatt--service_plans)) + + +### Nested Schema for `service_plans` + +Read-Only: + +- `annotations` (Map of String) The annotations associated with Cloud Foundry resources. +- `available` (Boolean) Whether or not the service plan is available +- `broker_catalog` (Attributes) This object contains information obtained from the service broker catalog (see [below for nested schema](#nestedatt--service_plans--broker_catalog)) +- `costs` (Attributes List) The cost of the service plan as obtained from the service broker catalog (see [below for nested schema](#nestedatt--service_plans--costs)) +- `created_at` (String) The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. +- `description` (String) Description of the service plan +- `free` (Boolean) Whether or not the service plan is free of charge +- `id` (String) The GUID of the object. +- `labels` (Map of String) The labels associated with Cloud Foundry resources. +- `maintenance_info` (Attributes) Information about the version of this service plan (see [below for nested schema](#nestedatt--service_plans--maintenance_info)) +- `name` (String) Name of the service plan +- `schemas` (Attributes) Schema definitions for service instances and service bindings for the service plan (see [below for nested schema](#nestedatt--service_plans--schemas)) +- `service_offering` (String) The service offering that this service plan relates to +- `updated_at` (String) The date and time when the resource was updated in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. +- `visibility_type` (String) Denotes the visibility of the plan + + +### Nested Schema for `service_plans.broker_catalog` + +Read-Only: + +- `bindable` (Boolean) Specifies whether service instances of the service can be bound to applications +- `id` (String) The identifier that the service broker provided for this service plan +- `maximum_polling_duration` (Number) The maximum number of seconds that Cloud Foundry will wait for an asynchronous service broker operation +- `metadata` (String) Additional information provided by the service broker as specified by OSBAPI +- `plan_updateable` (Boolean) Whether the service plan supports upgrade/downgrade for service plans + + + +### Nested Schema for `service_plans.costs` + +Read-Only: + +- `amount` (Number) Pricing amount +- `currency` (String) Currency code for the pricing amount, e.g. USD, GBP +- `unit` (String) Display name for type of cost, e.g. Monthly, Hourly, Request, GB + + + +### Nested Schema for `service_plans.maintenance_info` + +Read-Only: + +- `description` (String) A textual explanation associated with this version +- `version` (String) The current semantic version of the service plan + + + +### Nested Schema for `service_plans.schemas` + +Read-Only: + +- `service_binding` (Attributes) (see [below for nested schema](#nestedatt--service_plans--schemas--service_binding)) +- `service_instance` (Attributes) (see [below for nested schema](#nestedatt--service_plans--schemas--service_instance)) + + +### Nested Schema for `service_plans.schemas.service_binding` + +Read-Only: + +- `create_parameters` (String) Schema definition for the input parameters for service Binding creation + + + +### Nested Schema for `service_plans.schemas.service_instance` + +Read-Only: + +- `create_parameters` (String) Schema definition for the input parameters for service instance creation +- `update_parameters` (String) Schema definition for the input parameters for service instance update \ No newline at end of file diff --git a/docs/resources/service_instance.md b/docs/resources/service_instance.md index f557c0e..f6aecab 100644 --- a/docs/resources/service_instance.md +++ b/docs/resources/service_instance.md @@ -22,25 +22,27 @@ data "cloudfoundry_org" "team_org" { } data "cloudfoundry_space" "team_space" { - name = "PerformanceTeamBLR" + name = "tf-space-1" org = data.cloudfoundry_org.team_org.id } -data "cloudfoundry_service" "xsuaa_svc" { - name = "xsuaa" +data "cloudfoundry_service_plans" "xsuaa_svc" { + name = "application" + service_offering_name = "xsuaa" } -data "cloudfoundry_service" "autoscaler_svc" { - name = "autoscaler" +data "cloudfoundry_service_plans" "autoscaler_svc" { + name = "standard" + service_offering_name = "autoscaler" } resource "cloudfoundry_service_instance" "xsuaa_svc" { - name = "xsuaa_svc" + name = "xsuaa_sv1" type = "managed" tags = ["terraform-test", "test1"] space = data.cloudfoundry_space.team_space.id - service_plan = data.cloudfoundry_service.xsuaa_svc.service_plans["application"] + service_plan = data.cloudfoundry_service_plans.xsuaa_svc.service_plans[0].id parameters = <data "cloudfoundry_service" "redis" {
name = "p-redis"
}
|
data "cloudfoundry_service" "redis" {
name = "p-redis"
}
| - -## Differences - -> [!NOTE] -> 🔵 Required 🟢 Optional 🟠 Computed 🔴 Not present - -| Attribute name | SAP Cloud Foundry Provider (new)| Community Cloud Foundry Provider (old) | Description | -| --- | --- | --- | --- | -| service_broker_guid | 🔴 | 🟢 | `service_broker_guid`attribute has been changed to `service_broker` | -| service_broker | 🟢 | 🔴 | - | -| service_broker_name | 🔴 | 🟠 | - | -| space | 🔴 | 🟢 | - |