Skip to content

Commit

Permalink
V2 migration (CiscoDevNet#507)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashutosh Soni <[email protected]>
Co-authored-by: Lionel Hercot <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2021
1 parent 649ce4e commit f269251
Showing 2,344 changed files with 30,533 additions and 253,549 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 1.0.0 (October 25, 2021)
BREAKING CHANGE:
- Migration to Terraform Provider SDK v2. Remove support for Terraform v0.11.x or below
- Fix and update netflow monitor relation in aci_leaf_access_port_policy_group and aci_leaf_access_bundle_policy_group

IMPROVEMENTS:
- Update dependancy versions
- Fix examples formating in examples directory
- Add examples for resources without examples

BUG FIXES:
- Add support for aci_bgp_peer_connectivity_profile to be defined at interface level and node level
- Fix multiple idempotency issues accross resources
- Fix issues found during testing of resources with TF provider SDK v2
- Add forced replacement of resource if path or class_name is changed in aci_rest

## 0.7.1 (June 25, 2021)
BREAKING CHANGE:
- Change aci_dhcp_relay_policy relation_dhcp_rs_prov argument from list of string to block definition to accomodate the addr argument.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,9 @@
Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) v0.11.7
- [Terraform](https://www.terraform.io/downloads.html)
- v0.12 and higher (ACI Provider v1.0.0 or higher)
- v0.11.x or below (ACI Provider v0.7.1 or below)

- [Go](https://golang.org/doc/install) Latest Version

@@ -57,7 +59,7 @@ resource "aci_tenant" "test-tenant" {
}
resource "aci_app_profile" "test-app" {
tenant_dn = "${aci_tenant.test-tenant.id}"
tenant_dn = aci_tenant.test-tenant.id
name = "test-app"
description = "This app profile is created by terraform"
}
7 changes: 5 additions & 2 deletions aci/base_attr_schema.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aci

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

func GetBaseAttrSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -12,7 +12,10 @@ func GetBaseAttrSchema() map[string]*schema.Schema {
"annotation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "orchestrator:terraform",
Computed: true,
DefaultFunc: func() (interface{}, error) {
return "orchestrator:terraform", nil
},
},
}
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_aaadomain.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciSecurityDomain() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciSecurityDomainRead,
ReadContext: dataSourceAciSecurityDomainRead,

SchemaVersion: 1,

@@ -30,7 +32,7 @@ func dataSourceAciSecurityDomain() *schema.Resource {
}
}

func dataSourceAciSecurityDomainRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciSecurityDomainRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -42,8 +44,11 @@ func dataSourceAciSecurityDomainRead(d *schema.ResourceData, m interface{}) erro
aaaDomain, err := getRemoteSecurityDomain(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}
_, err = setSecurityDomainAttributes(aaaDomain, d)
if err != nil {
return diag.FromErr(err)
}
setSecurityDomainAttributes(aaaDomain, d)
return nil
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_aaauser.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciLocalUser() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciLocalUserRead,
ReadContext: dataSourceAciLocalUserRead,

SchemaVersion: 1,

@@ -126,7 +128,7 @@ func dataSourceAciLocalUser() *schema.Resource {
}
}

func dataSourceAciLocalUserRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciLocalUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -138,8 +140,11 @@ func dataSourceAciLocalUserRead(d *schema.ResourceData, m interface{}) error {
aaaUser, err := getRemoteLocalUser(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}
_, err = setLocalUserAttributes(aaaUser, d)
if err != nil {
return diag.FromErr(err)
}
setLocalUserAttributes(aaaUser, d)
return nil
}
18 changes: 12 additions & 6 deletions aci/data_source_aci_aaausercert.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciX509Certificate() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciX509CertificateRead,
ReadContext: dataSourceAciX509CertificateRead,

SchemaVersion: 1,

@@ -40,7 +42,7 @@ func dataSourceAciX509Certificate() *schema.Resource {
}
}

func dataSourceAciX509CertificateRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciX509CertificateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -51,11 +53,15 @@ func dataSourceAciX509CertificateRead(d *schema.ResourceData, m interface{}) err
dn := fmt.Sprintf("%s/%s", LocalUserDn, rn)

aaaUserCert, err := getRemoteX509Certificate(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}

d.SetId(dn)
setX509CertificateAttributes(aaaUserCert, d)
_, err = setX509CertificateAttributes(aaaUserCert, d)
if err != nil {
return diag.FromErr(err)
}

return nil
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_bfdifp.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciBFDInterfaceProfile() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciBFDInterfaceProfileRead,
ReadContext: dataSourceAciBFDInterfaceProfileRead,

SchemaVersion: 1,

@@ -53,7 +55,7 @@ func dataSourceAciBFDInterfaceProfile() *schema.Resource {
}
}

func dataSourceAciBFDInterfaceProfileRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciBFDInterfaceProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

rn := fmt.Sprintf("bfdIfP")
@@ -64,10 +66,13 @@ func dataSourceAciBFDInterfaceProfileRead(d *schema.ResourceData, m interface{})
bfdIfP, err := getRemoteBFDInterfaceProfile(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}

d.SetId(dn)
setBFDInterfaceProfileAttributes(bfdIfP, d)
_, err = setBFDInterfaceProfileAttributes(bfdIfP, d)
if err != nil {
return diag.FromErr(err)
}
return nil
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_bgpbestpathctrlpol.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciBgpBestPathPolicy() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciBgpBestPathPolicyRead,
ReadContext: dataSourceAciBgpBestPathPolicyRead,

SchemaVersion: 1,

@@ -46,7 +48,7 @@ func dataSourceAciBgpBestPathPolicy() *schema.Resource {
}
}

func dataSourceAciBgpBestPathPolicyRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciBgpBestPathPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -59,9 +61,12 @@ func dataSourceAciBgpBestPathPolicyRead(d *schema.ResourceData, m interface{}) e
bgpBestPathCtrlPol, err := getRemoteBgpBestPathPolicy(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}
d.SetId(dn)
setBgpBestPathPolicyAttributes(bgpBestPathCtrlPol, d)
_, err = setBgpBestPathPolicyAttributes(bgpBestPathCtrlPol, d)
if err != nil {
return diag.FromErr(err)
}
return nil
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_bgpctxafpol.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciBGPAddressFamilyContextPolicy() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciBGPAddressFamilyContextPolicyRead,
ReadContext: dataSourceAciBGPAddressFamilyContextPolicyRead,

SchemaVersion: 1,

@@ -76,7 +78,7 @@ func dataSourceAciBGPAddressFamilyContextPolicy() *schema.Resource {
}
}

func dataSourceAciBGPAddressFamilyContextPolicyRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciBGPAddressFamilyContextPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -89,10 +91,13 @@ func dataSourceAciBGPAddressFamilyContextPolicyRead(d *schema.ResourceData, m in
bgpCtxAfPol, err := getRemoteBGPAddressFamilyContextPolicy(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}

d.SetId(dn)
setBGPAddressFamilyContextPolicyAttributes(bgpCtxAfPol, d)
_, err = setBGPAddressFamilyContextPolicyAttributes(bgpCtxAfPol, d)
if err != nil {
return diag.FromErr(err)
}
return nil
}
15 changes: 10 additions & 5 deletions aci/data_source_aci_bgpctxpol.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package aci

import (
"context"
"fmt"

"github.com/ciscoecosystem/aci-go-client/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAciBGPTimersPolicy() *schema.Resource {
return &schema.Resource{

Read: dataSourceAciBGPTimersPolicyRead,
ReadContext: dataSourceAciBGPTimersPolicyRead,

SchemaVersion: 1,

@@ -70,7 +72,7 @@ func dataSourceAciBGPTimersPolicy() *schema.Resource {
}
}

func dataSourceAciBGPTimersPolicyRead(d *schema.ResourceData, m interface{}) error {
func dataSourceAciBGPTimersPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)

name := d.Get("name").(string)
@@ -83,10 +85,13 @@ func dataSourceAciBGPTimersPolicyRead(d *schema.ResourceData, m interface{}) err
bgpCtxPol, err := getRemoteBGPTimersPolicy(aciClient, dn)

if err != nil {
return err
return diag.FromErr(err)
}

d.SetId(dn)
setBGPTimersPolicyAttributes(bgpCtxPol, d)
_, err = setBGPTimersPolicyAttributes(bgpCtxPol, d)
if err != nil {
return diag.FromErr(err)
}
return nil
}
Loading

0 comments on commit f269251

Please sign in to comment.