Skip to content

Commit

Permalink
Change mta datasource to mtas
Browse files Browse the repository at this point in the history
  • Loading branch information
Dray56 authored and debTheRay committed Oct 16, 2024
1 parent ad2214e commit 4f4022d
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions docs/data-sources/mta.md → docs/data-sources/mtas.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
page_title: "cloudfoundry_mta Data Source - terraform-provider-cloudfoundry"
page_title: "cloudfoundry_mtas Data Source - terraform-provider-cloudfoundry"
subcategory: ""
description: |-
Gets information on Multi Target Applications present in a space.
---

# cloudfoundry_mta (Data Source)
# cloudfoundry_mtas (Data Source)

Gets information on Multi Target Applications present in a space.

## Example Usage

```terraform
data "cloudfoundry_mta" "mtars" {
data "cloudfoundry_mtas" "mtas" {
space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143"
namespace = "test"
}
output "data" {
value = data.cloudfoundry_mtar.mtars
value = data.cloudfoundry_mtas.mtas
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
data "cloudfoundry_mta" "mtars" {
data "cloudfoundry_mtas" "mtas" {
space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143"
namespace = "test"
}

output "data" {
value = data.cloudfoundry_mtar.mtars
value = data.cloudfoundry_mtas.mtas
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ import (

// Ensure provider defined types fully satisfy framework interfaces.
var (
_ datasource.DataSource = &MtaDataSource{}
_ datasource.DataSourceWithConfigure = &MtaDataSource{}
_ datasource.DataSource = &MtasDataSource{}
_ datasource.DataSourceWithConfigure = &MtasDataSource{}
)

// Instantiates a mtar data source.
func NewMtaDataSource() datasource.DataSource {
return &MtaDataSource{}
func NewMtasDataSource() datasource.DataSource {
return &MtasDataSource{}
}

// Contains reference to the mta client to be used for making the API calls.
type MtaDataSource struct {
type MtasDataSource struct {
mtaClient *mta.APIClient
}

func (d *MtaDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_mta"
func (d *MtasDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_mtas"
}

func (d *MtaDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
func (d *MtasDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
Expand All @@ -61,7 +61,7 @@ func (d *MtaDataSource) Configure(ctx context.Context, req datasource.ConfigureR
d.mtaClient.ChangeBasePath(deployURL)
}

func (d *MtaDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
func (d *MtasDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "Gets information on Multi Target Applications present in a space.",

Expand Down Expand Up @@ -151,7 +151,7 @@ func (d *MtaDataSource) Schema(ctx context.Context, req datasource.SchemaRequest
}
}

func (d *MtaDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *MtasDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var (
data MtarDataSourceType
namespace *string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

type MtaDataSourceModelPtr struct {
type MtasDataSourceModelPtr struct {
HclType string
HclObjectName string
Space *string
Expand All @@ -33,10 +33,10 @@ type MtaResourceModelPtr struct {
SourceCodeHash *string
}

func hclDataSourceMta(mdsmp *MtaDataSourceModelPtr) string {
func hclDataSourceMta(mdsmp *MtasDataSourceModelPtr) string {
if mdsmp != nil {
s := `
{{.HclType}} "cloudfoundry_mta" {{.HclObjectName}} {
{{.HclType}} "cloudfoundry_mtas" {{.HclObjectName}} {
{{- if .Space}}
space = "{{.Space}}"
{{- end -}}
Expand Down Expand Up @@ -64,7 +64,7 @@ func hclDataSourceMta(mdsmp *MtaDataSourceModelPtr) string {
}
return buf.String()
}
return mdsmp.HclType + ` "cloudfoundry_mta "` + mdsmp.HclObjectName + ` {}`
return mdsmp.HclType + ` "cloudfoundry_mtas "` + mdsmp.HclObjectName + ` {}`
}

func hclResourceMta(mrmp *MtaResourceModelPtr) string {
Expand Down Expand Up @@ -113,25 +113,25 @@ func hclResourceMta(mrmp *MtaResourceModelPtr) string {
return mrmp.HclType + ` "cloudfoundry_mta "` + mrmp.HclObjectName + ` {}`
}

func TestMtaDataSource_Configure(t *testing.T) {
func TestMtasDataSource_Configure(t *testing.T) {
var (
//canary->tf-space-1
mtaId = "a.cf.app"
spaceGuid = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143"
)
t.Parallel()
dataSourceName := "data.cloudfoundry_mta.ds"
dataSourceName := "data.cloudfoundry_mtas.ds"
t.Run("happy path - read mtar", func(t *testing.T) {
cfg := getCFHomeConf()
rec := cfg.SetupVCR(t, "fixtures/datasource_mta")
rec := cfg.SetupVCR(t, "fixtures/datasource_mtas")
defer stopQuietly(rec)

resource.Test(t, resource.TestCase{
IsUnitTest: true,
ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()),
Steps: []resource.TestStep{
{
Config: hclProvider(nil) + hclDataSourceMta(&MtaDataSourceModelPtr{
Config: hclProvider(nil) + hclDataSourceMta(&MtasDataSourceModelPtr{
HclType: hclObjectDataSource,
HclObjectName: "ds",
Space: strtostrptr(spaceGuid),
Expand All @@ -148,15 +148,15 @@ func TestMtaDataSource_Configure(t *testing.T) {
})
t.Run("error path - mtar does not exist", func(t *testing.T) {
cfg := getCFHomeConf()
rec := cfg.SetupVCR(t, "fixtures/datasource_mta_invalid")
rec := cfg.SetupVCR(t, "fixtures/datasource_mtas_invalid")
defer stopQuietly(rec)

resource.Test(t, resource.TestCase{
IsUnitTest: true,
ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()),
Steps: []resource.TestStep{
{
Config: hclProvider(nil) + hclDataSourceMta(&MtaDataSourceModelPtr{
Config: hclProvider(nil) + hclDataSourceMta(&MtasDataSourceModelPtr{
HclType: hclObjectDataSource,
HclObjectName: "ds",
Space: strtostrptr(spaceGuid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ interactions:
trailer: {}
content_length: -1
uncompressed: true
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"o"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"o-my-cf-app","providedDendencyNames":[],"services":[],"uris":["o-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"1.0.0"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"my-cf-app","providedDendencyNames":[],"services":[],"uris":["performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hi"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hi-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hi-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hello"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hello-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hello-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"test"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"test-my-cf-app","providedDendencyNames":[],"services":[],"uris":["test-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
headers:
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Content-Type:
- application/json
Date:
- Wed, 22 May 2024 05:57:31 GMT
- Wed, 16 Oct 2024 06:08:54 GMT
Expires:
- "0"
Pragma:
- no-cache
Server:
- ""
Set-Cookie:
- JSESSIONID=FCE300340E1A7834D64A873DA8965CBA; Path=/; Secure; HttpOnly
- __VCAP_ID__=1fc8ac61-8593-496b-559c-2a4e; Path=/; HttpOnly; Secure
- JSESSIONID=1321DD28B799D346BC72A4E350520197; Path=/; Secure; HttpOnly
- __VCAP_ID__=5ddc1f49-43c9-4151-6c09-65f7; Path=/; HttpOnly; Secure
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload;
Vary:
Expand All @@ -55,12 +55,12 @@ interactions:
X-Frame-Options:
- DENY
X-Vcap-Request-Id:
- dc557d3a-71f8-4461-6b38-f162f71ad2b9
- d515f3a6-c420-4305-5c3d-679807cc15c2
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: 1.652181s
duration: 1.518325333s
- id: 1
request:
proto: HTTP/1.1
Expand Down Expand Up @@ -89,23 +89,23 @@ interactions:
trailer: {}
content_length: -1
uncompressed: true
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"o"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"o-my-cf-app","providedDendencyNames":[],"services":[],"uris":["o-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"1.0.0"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"my-cf-app","providedDendencyNames":[],"services":[],"uris":["performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hi"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hi-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hi-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hello"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hello-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hello-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"test"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"test-my-cf-app","providedDendencyNames":[],"services":[],"uris":["test-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
headers:
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Content-Type:
- application/json
Date:
- Wed, 22 May 2024 05:57:33 GMT
- Wed, 16 Oct 2024 06:08:55 GMT
Expires:
- "0"
Pragma:
- no-cache
Server:
- ""
Set-Cookie:
- JSESSIONID=AFF6AE8234CA81BD442A24712AB9549E; Path=/; Secure; HttpOnly
- __VCAP_ID__=2034bff3-5c1c-4e01-43df-f2b1; Path=/; HttpOnly; Secure
- JSESSIONID=A58E1A5550331D277554DDD9E8652EDB; Path=/; Secure; HttpOnly
- __VCAP_ID__=98f3a52e-4b27-4302-7862-3aa3; Path=/; HttpOnly; Secure
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload;
Vary:
Expand All @@ -115,12 +115,12 @@ interactions:
X-Frame-Options:
- DENY
X-Vcap-Request-Id:
- ad3a42b8-00a6-44c8-4ace-7f1e024cf4ac
- 535b4e5d-4dc5-4590-67c7-e31682ed0c5b
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: 1.550469625s
duration: 923.747208ms
- id: 2
request:
proto: HTTP/1.1
Expand Down Expand Up @@ -149,23 +149,23 @@ interactions:
trailer: {}
content_length: -1
uncompressed: true
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"o"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"o-my-cf-app","providedDendencyNames":[],"services":[],"uris":["o-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"1.0.0"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"my-cf-app","providedDendencyNames":[],"services":[],"uris":["performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hi"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hi-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hi-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
body: '[{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"hello"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"hello-my-cf-app","providedDendencyNames":[],"services":[],"uris":["hello-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]},{"metadata":{"id":"a.cf.app","version":"0.0.0","namespace":"test"},"modules":[{"moduleName":"my-mta-managed-app-module","appName":"test-my-cf-app","providedDendencyNames":[],"services":[],"uris":["test-performanceteamblr-tf-space-1-my-mta-managed-app-module.cfapps.sap.hana.ondemand.com"]}],"services":[]}]'
headers:
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Content-Type:
- application/json
Date:
- Wed, 22 May 2024 05:57:33 GMT
- Wed, 16 Oct 2024 06:08:56 GMT
Expires:
- "0"
Pragma:
- no-cache
Server:
- ""
Set-Cookie:
- JSESSIONID=DC921FCABC43B54E4CB099B50D328A6F; Path=/; Secure; HttpOnly
- __VCAP_ID__=1fc8ac61-8593-496b-559c-2a4e; Path=/; HttpOnly; Secure
- JSESSIONID=2E47D0067B51208F3F2F9B7A2FB2613A; Path=/; Secure; HttpOnly
- __VCAP_ID__=98f3a52e-4b27-4302-7862-3aa3; Path=/; HttpOnly; Secure
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload;
Vary:
Expand All @@ -175,9 +175,9 @@ interactions:
X-Frame-Options:
- DENY
X-Vcap-Request-Id:
- 1b027a41-746a-4888-43ee-1096f4b0f7d5
- 3831fbdd-b1e7-4cfa-7b3f-126dbfa88df1
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: 571.22675ms
duration: 723.114084ms
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ interactions:
Content-Type:
- text/plain;charset=UTF-8
Date:
- Wed, 22 May 2024 05:57:34 GMT
- Wed, 16 Oct 2024 06:08:56 GMT
Expires:
- "0"
Pragma:
- no-cache
Server:
- ""
Set-Cookie:
- JSESSIONID=9D4392A968402D6D1ABEA5B247BE44A8; Path=/; Secure; HttpOnly
- __VCAP_ID__=4244dfe0-f7aa-43bc-68df-2ac7; Path=/; HttpOnly; Secure
- JSESSIONID=102525A05FF5497DA3C1AC3CE17C3932; Path=/; Secure; HttpOnly
- __VCAP_ID__=5c9f131a-eaf9-4ebb-4adc-3abe; Path=/; HttpOnly; Secure
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload;
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Vcap-Request-Id:
- a67faaa4-d3a9-4535-5d2e-18af3e1ad4ed
- 4b1bcf75-1ae5-4bc9-6751-f593e289e715
X-Xss-Protection:
- 1; mode=block
status: 404 Not Found
code: 404
duration: 365.966042ms
duration: 592.97875ms
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (p *CloudFoundryProvider) DataSources(ctx context.Context) []func() datasou
NewDomainDataSource,
NewAppDataSource,
NewServiceCredentialBindingDataSource,
NewMtaDataSource,
NewMtasDataSource,
NewIsolationSegmentDataSource,
NewIsolationSegmentEntitlementDataSource,
NewStackDataSource,
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestProvider_HasDataSources(t *testing.T) {
"cloudfoundry_domain",
"cloudfoundry_app",
"cloudfoundry_service_credential_binding",
"cloudfoundry_mta",
"cloudfoundry_mtas",
"cloudfoundry_isolation_segment",
"cloudfoundry_isolation_segment_entitlement",
"cloudfoundry_stack",
Expand Down
4 changes: 2 additions & 2 deletions migration-guide/Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Migration Guide

Although the definitions look similar the Terraform providers of the [cloudfoundry-community](https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry) and [SAP](https://github.com/cloudfoundry/terraform-provider-cloudfoundry) are not the same. They differ in the definition as well as the state structure especially due to the usage if the V3 API in the newer provider.
Although the definitions look similar the Terraform providers of the [cloudfoundry-community](https://github.com/cloudfoundry-community/terraform-provider-cloudfoundry) and [cloudfoundry](https://github.com/cloudfoundry/terraform-provider-cloudfoundry) are not the same. They differ in the definition as well as the state structure especially due to the usage if the V3 API in the newer provider.

Therefore, the providers cannot be simply interchanged. If you want to switch you must rewrite your configuration. Additionally you must import the resources to create a state consistent with the new provider.

Expand Down Expand Up @@ -194,7 +194,7 @@ Few resources required a major change in functionality or the way the resources

The below mentioned dataSources have been newly added in the current provider.

- [Multi Target Application Deployment](../docs/data-sources/mta.md)
- [Multi Target Application Deployment](../docs/data-sources/mtas.md)
- [Isolation Segment Entitlement](../docs/data-sources/isolation_segment_entitlement.md)
- [Role](../docs/data-sources/role.md)
- [Users](../docs/data-sources/users.md)
Expand Down

0 comments on commit 4f4022d

Please sign in to comment.