Skip to content

Commit

Permalink
fixes issue on resource fabrics associations
Browse files Browse the repository at this point in the history
  • Loading branch information
soufi committed Aug 13, 2024
1 parent fdeaf4e commit 3e82ae8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
5 changes: 5 additions & 0 deletions anypoint/provider_clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
apim "github.com/mulesoft-anypoint/anypoint-client-go/apim"
"github.com/mulesoft-anypoint/anypoint-client-go/apim_policy"
apim_upstream "github.com/mulesoft-anypoint/anypoint-client-go/apim_upstream"
application_manager "github.com/mulesoft-anypoint/anypoint-client-go/application_manager"
connected_app "github.com/mulesoft-anypoint/anypoint-client-go/connected_app"
dlb "github.com/mulesoft-anypoint/anypoint-client-go/dlb"
env "github.com/mulesoft-anypoint/anypoint-client-go/env"
Expand Down Expand Up @@ -64,6 +65,7 @@ type ProviderConfOutput struct {
sgtlscontextclient *secretgroup_tlscontext.APIClient
sgcrldistribcfgsclient *secretgroup_crl_distributor_configs.APIClient
rtfclient *rtf.APIClient
appmanagerclient *application_manager.APIClient
}

func newProviderConfOutput(access_token string, server_index int) ProviderConfOutput {
Expand Down Expand Up @@ -97,6 +99,7 @@ func newProviderConfOutput(access_token string, server_index int) ProviderConfOu
sgtlscontextcfg := secretgroup_tlscontext.NewConfiguration()
sgcrldistribcfgs_cfg := secretgroup_crl_distributor_configs.NewConfiguration()
rtf_cfg := rtf.NewConfiguration()
appmanager_cfg := application_manager.NewConfiguration()

vpcclient := vpc.NewAPIClient(vpccfg)
vpnclient := vpn.NewAPIClient(vpncfg)
Expand Down Expand Up @@ -127,6 +130,7 @@ func newProviderConfOutput(access_token string, server_index int) ProviderConfOu
sgtlscontextclient := secretgroup_tlscontext.NewAPIClient(sgtlscontextcfg)
sgcrldistribcfgsclient := secretgroup_crl_distributor_configs.NewAPIClient(sgcrldistribcfgs_cfg)
rtfclient := rtf.NewAPIClient(rtf_cfg)
appmanagerclient := application_manager.NewAPIClient(appmanager_cfg)

return ProviderConfOutput{
access_token: access_token,
Expand Down Expand Up @@ -160,5 +164,6 @@ func newProviderConfOutput(access_token string, server_index int) ProviderConfOu
sgtlscontextclient: sgtlscontextclient,
sgcrldistribcfgsclient: sgcrldistribcfgsclient,
rtfclient: rtfclient,
appmanagerclient: appmanagerclient,
}
}
17 changes: 3 additions & 14 deletions anypoint/resource_fabrics_associations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func resourceFabricsAssociations() *schema.Resource {
DeleteContext: resourceFabricsAssociationsDelete,
Description: `
Manages ` + "`" + `Runtime Fabrics` + "`" + ` Environment associations.
NOTE: The fabrics will be associated with all sandbox environments in every available org when this resource is deleted.
`,
Schema: map[string]*schema.Schema{
"last_updated": {
Expand All @@ -41,15 +42,6 @@ func resourceFabricsAssociations() *schema.Resource {
ForceNew: true,
Description: "The unique id of the fabrics instance in the platform.",
},
"is_production": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
Description: `
If activated, the fabrics will be associated with all production environments in every available org if the resource is deleted. Otherwise, sandbox environments will be used.
`,
},
"associations": {
Type: schema.TypeSet,
Required: true,
Expand Down Expand Up @@ -157,8 +149,9 @@ func resourceFabricsAssociationsRead(ctx context.Context, d *schema.ResourceData
})
return diags
}
d.SetId(fabricsid)
d.SetId(ComposeResourceId([]string{orgid, fabricsid}))
d.Set("org_id", orgid)
d.Set("fabrics_id", fabricsid)
return diags
}

Expand Down Expand Up @@ -217,13 +210,9 @@ func prepareFabricsAssociationsPostBody(d *schema.ResourceData) *rtf.FabricsAsso
}

func prepareFabricsAssociationsDeleteBody(d *schema.ResourceData) *rtf.FabricsAssociationsPostBody {
is_production := d.Get("is_production").(bool)
body := rtf.NewFabricsAssociationsPostBody()
env := "sandbox"
org := "all"
if is_production {
env = "production"
}
associations := []rtf.FabricsAssociationsPostBodyAssociationsInner{
{
Environment: &env,
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/mulesoft-anypoint/anypoint-client-go/apim v0.1.0
github.com/mulesoft-anypoint/anypoint-client-go/apim_policy v0.0.1
github.com/mulesoft-anypoint/anypoint-client-go/apim_upstream v0.0.1
github.com/mulesoft-anypoint/anypoint-client-go/application_manager v0.1.0
github.com/mulesoft-anypoint/anypoint-client-go/authorization v0.3.0
github.com/mulesoft-anypoint/anypoint-client-go/connected_app v1.1.1
github.com/mulesoft-anypoint/anypoint-client-go/dlb v0.5.0
Expand All @@ -20,6 +21,7 @@ require (
github.com/mulesoft-anypoint/anypoint-client-go/org v0.4.0
github.com/mulesoft-anypoint/anypoint-client-go/role v0.2.0
github.com/mulesoft-anypoint/anypoint-client-go/rolegroup v0.2.0
github.com/mulesoft-anypoint/anypoint-client-go/rtf v0.0.1
github.com/mulesoft-anypoint/anypoint-client-go/secretgroup v0.1.0
github.com/mulesoft-anypoint/anypoint-client-go/secretgroup_certificate v0.1.0
github.com/mulesoft-anypoint/anypoint-client-go/secretgroup_crl_distributor_configs v0.1.0
Expand All @@ -34,8 +36,6 @@ require (
github.com/mulesoft-anypoint/anypoint-client-go/user_rolegroups v0.2.0
github.com/mulesoft-anypoint/anypoint-client-go/vpc v0.6.0
github.com/mulesoft-anypoint/anypoint-client-go/vpn v0.1.0
github.com/mulesoft-anypoint/anypoint-client-go/rtf v0.0.1
github.com/mulesoft-anypoint/anypoint-client-go/application_manager v0.0.1
)

require (
Expand Down Expand Up @@ -82,4 +82,5 @@ require (
)

replace github.com/mulesoft-anypoint/anypoint-client-go/rtf => /Users/souf/Workspaces/CAT/Anypoint-Devops-Collective/anypoint-automation-client-generator/dist/rtf

replace github.com/mulesoft-anypoint/anypoint-client-go/application_manager => /Users/souf/Workspaces/CAT/Anypoint-Devops-Collective/anypoint-automation-client-generator/dist/application_manager

0 comments on commit 3e82ae8

Please sign in to comment.